akhauriyash/Code-Regression huggingface dataset:
def main():
    K, S = (int(i) for i in input().split())
    ans = 0
    for i in range(K+1):
        for j in range(K+1):
            k = S - i - j
            if 0 <= k <= K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41308
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#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;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int x;
   cin>>x;
   if(x>=30)
   {
       cout<<"Yes"<<endl;
   }
   else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3640
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    a, b, c = gets.split.map(&:to_i)

    if 22 <= a + b + c
      puts "bust"
    else
      puts "win"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double n;
  cin >> n;
  vector<double> a(n);
  double cnt=0;
  REP(i,n){
      cin >> a[i];
      cnt+= a[i];
  }
  cnt = cnt / n;
  int pos ;
  double ax = INF;
  REP(i,n){
      if(abs(ax-cnt) > abs(a[i]-cnt)){
          ax = a[i];
          pos = i;
      }
  }
  cout << pos << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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;
    }
}
int main(void)
{
    lli N;
    cin >> N;
    lli a[N];
    lli b[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++)
    {
        b[i] = a[i];
    }
    sort(b, b + N);
    lli mxnum = b[N - 1];
    lli sum = 0;
    int idx = N;
    for (int i = 1; i < N; i++)
    {
        if (a[i] == mxnum)
        {
            idx = i;
            break;
        }
        else
        {
            if (a[i - 1] > a[i])
            {
                sum += a[i - 1] - a[i];
                a[i] += a[i - 1] - a[i];
            }
        }
    }
    for (int i = idx; i < N; i++)
    {
        sum += mxnum - a[i];
    }
    cout << sum << endl;
    return 0;
}

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

int main()
{
  int S;
  cin >> S;
  int a[4];
  for(int i = 0; i < 4; i++) {
    a[i] = S % 10;
    S /= 10;
  }
  string result = "Good";
  for(int i = 1; i < 4; i++) {
     if(a[i - 1] == a[i])
       result = "Bad";
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if((A==5&&B==5&&C==7)||(A==5&&C==5&&B==7)||(B==5&&C==5&&A==7)){
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    return 0;
}

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

int main()
{
    int a1,a2,a3,a4;
    while(~scanf("%d",&a1))
    {
        if(a1==1)
        {
            printf("Hello World\n");
        }
        if(a1==2)
        {
            scanf("%d",&a2);
            scanf("%d",&a3);
            printf("%d\n",a2+a3);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int H, W, K;
    cin >> H >> W >> K;
    ll dp[H + 1][W + 1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    int mod = 1e9 + 7;

    rep(i, 0, H) {
        rep(j, 0, W) {
            for(int mask = 0; mask < 1 << (W - 1); mask++) {
                bool flag = true;
                rep(l, 0, W - 2) {
                    if((mask & (1 << l)) and (mask & 1 << (l + 1))) flag = false;
                }
                if(flag) {
                    if(j >= 1 and mask & 1 << (j - 1)) {
                        (dp[i + 1][j - 1] += dp[i][j]) %= mod;
                    } else if(j <= W - 2 and mask & 1 << j) {
                        (dp[i + 1][j + 1] += dp[i][j]) %= mod;
                    } else {
                        (dp[i + 1][j] += dp[i][j]) %= mod;
                    }
                }
            }
        }
    }

    cout << dp[H][K - 1] << endl;

}


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

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

ll runrun(ll a) {
	queue<ll> Q;
	for (ll i = 1; i < 10;i++) {
		Q.push(i);
	}

	ll count = 1;

	while (1) {
		ll x = Q.front();
		Q.pop();

		if (a==count) {
			return x;
		}
		else {
			if (x % 10 != 0) {
				Q.push(x * 10 + (x % 10 -1));
			}

			Q.push(x * 10 + (x % 10));

			if (x % 10 != 9) {
				Q.push(x * 10 + (x % 10 + 1));
			}
		}

		count++;
	}
}

int main(void) {
	ll k;
	cin >> k;

	cout << runrun(k) << endl;

	return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

int n,k;
int a[5001];
bool dp[5001][5001],dp2[5001][5001];

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>k;

    dp[0][0]=true;
    rep(i,n){
        cin>>a[i];
        rep(j,k){
            if(dp[i][j]){
                dp[i+1][j]=true;
                if(j+a[i]<k)dp[i+1][j+a[i]]=true;
            }
        }
    }

    dp2[n][0]=true;
    for(int i=n-1; i>=0; i--){
        rep(j,k){
            if(dp2[i+1][j]){
                dp2[i][j]=true;
                if(j+a[i]<k)dp2[i][j+a[i]]=true;
            }
        }
    }

    int ans=0;
    rep(i,n){
        vector<int> vec,vec2;
        rep(j,k){
            if(dp[i][j])vec.push_back(j);
            if(dp2[i+1][j])vec2.push_back(j);
        }
        bool need=false;
        rep(j,vec.size()){
            if(lower_bound(all(vec2),k-vec.at(j))-lower_bound(all(vec2),k-a[i]-vec.at(j)))need=true;
        }
        if(!need)ans++;
    }
    cout<<ans<<endl;

}

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

ll power10( ll n)
{
    ll ans=1;
    for( ll i=0;i<n;i++)ans= (ans*10)%K;
    return ans;
}
int main() {
	/*ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    */
    ll n;
    cin>>n;
    
    ll a=1,b=1,c=1;
    for(ll i=0;i<n;i++)
    {
        a=(a*10)%K;
        b=(b*9)%K;
        c=(c*8)%K;
    }
     cout<< ((a+c)%K- (2*b)%K + K) %K ;
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main(){
    
    int n; cin >> n;
    vector<pair<int, pair<int, int> > > p(n);
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        p[i].second.first = a;
        p[i].second.second = b;
        p[i].first = a + b;
    }

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < p.size(); i++){
        if(i % 2 == 0) ans += p[i].second.first;
        else ans -= p[i].second.second;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
N, P = map(int, input().split())
A = list(map(int, input().split()))

even, odd = 0, 0
for A_i in A:
    if A_i % 2 == 0:
        even += 1
    else:
        odd += 1

if odd == 0:
    if P == 0:
        ans = 2**N
    else:
        ans = 0
else:
    ans = 2**(N-1)

print(ans)

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

using namespace std;

void bfs(int src, vector<vector<int>>& graph, vector<int>& dist){
  queue<int> q;
  q.push(src);
  dist[src] = 0;
  while(!q.empty()){
    int node = q.front();
    q.pop();
    for(int next : graph[node]){
      if(dist[next] == -1){
        dist[next] = dist[node] + 1;
        q.push(next);
      }
    }
  }
}

int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  
  X--; Y--;
  vector<vector<int>> graph(N);
  graph[X].push_back(Y);
  graph[Y].push_back(X);
  for(int i = 0; i < N - 1; i++){
    graph[i].push_back(i + 1);
    graph[i + 1].push_back(i);
  }
  
  vector<vector<int>> dist(N, vector<int>(N, -1));
  
  for(int i = 0; i < N; i++){
    bfs(i, graph, dist[i]);
  }
  
  vector<long long> count(N, 0);
  
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      count[dist[i][j]]++;
    }
  }
  
  for(int i = 1; i < N; i++){
    cout << count[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 16128
# n = int(raw_input())
# a = [int(raw_input()) for i in xrange(n)]
a, b, c = map(int, raw_input().split())
k = int(raw_input())
# print "".join(["a","b"])
 
# print "Yes" if 3 > 0 else "No"
 
 
l = sorted([a,b,c])
m=l[2]
 
for i in xrange(k):
    m *= 2

print m + l[0] + l[1]

Measured memory_bytes: 2568
package main

import (
	"fmt"
)

func main() {
	var n, m, x int
	fmt.Scanf("%d %d %d", &n, &m, &x)

	left, right := 0, 0
	for i := 0; i < m; i++ {
		var a int
		fmt.Scanf("%d", &a)
		if a < x {
			left += 1
		} else {
			right += 1
		}
	}

	res := left
	if left > right {
		res = right
	}
	fmt.Println(res)
}


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

int main(){
  int x,y;
  cin >> x >> y;
  
  bool flag = false;
 
  rep(i,x+1){
    if(2*i+4*(x-i) == y) flag = true;
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    ss = input()
    odd = ["R","U","D"]
    even = ["L","U","D"]
    for s in ss[::2]:
        if not s in odd:
            return False
    for s in ss[1::2]:
        if not s in even:
            return False
    return True

if __name__ == '__main__':
    if main():
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 5716
# b
require 'pp'
A, B, M = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

xyc = []
M.times do
  xyc << gets.split.map(&:to_i)
end


min = [a.min + b.min]
M.times do |i|
  x = xyc[i][0] - 1
  y = xyc[i][1] - 1
  c = xyc[i][2]
  min << a[x] + b[y] - c
end
p min.min




Measured memory_bytes: 19652
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;

int sort(const void *a, const void *b){
  int A = *(int *)a, B = *(int *)b;
  if(A > B) return  1;
  if(A < B) return -1;
  return 0;
}

int
main(int argc, char *argv[])
{
  int n;
  int h[100000];
  scanf("%d", &n);
  rep(i, n) scanf("%d", &h[i]);

  int flag = 0;
  for(int i = n - 2; i >= 0; i--){
    if(h[i] - 1 == h[i + 1]) h[i]--;
    if(h[i] - 1 > h[i + 1]){
      flag++;
      break;
    }
  }

  if(flag > 0) printf("No\n");
  else printf("Yes\n");

  return 0;
}


Measured memory_bytes: 512
s = input()
t = input()

soln = ""

for i in range(len(s)-len(t)+1):
    sol = True
    for j in range(len(t)):
        if not (s[i+j] == t[j] or s[i+j] == "?"):
            sol = False
            break

    if sol:
        soln = s[:i] + t + s[i+len(t):]

print(soln.replace("?", "a") if soln != "" else "UNRESTORABLE")

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

/**
|||||||||||||       |||||     |||||    ||||||||||
||||||||||||||      |||||     |||||  |||||
|||||     |||||     |||||     |||||  |||||
||||||||||||||||    |||||||||||||||    ||||||||||
|||||||||||||||||   |||||||||||||||           |||||
|||||        |||||  |||||     |||||           |||||
|||||         ||||| |||||     |||||    ||||||||||
AHMED;HASSAN;SAEED;
*/

using namespace std;
long long n=100002;
vector<long long>vs(n+1,0);
vector<long long>cr(n+1,0);
vector<long long>dmg(n+1,0);
long long strs(long long i=0){
    if(vs[i])
        return cr[i];
    vs[i]=1;
    if(dmg[i])
        return (cr[i]=0);
    if(i==n-1){
        return (cr[i]=1);
    }
    if(i==n){
        return (cr[i]=1);
    }
        cr[i]=(strs(i+1)%1000000007+strs(i+2)%1000000007);
    return (cr[i]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int t;
        cin>>t;
        dmg[t]=1;
    }
    cout << strs()%1000000007<< endl;
    return 0;
}


Measured memory_bytes: 5760
using System;
using System.Collections.Generic;


class Program
{

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        
        if(n == 3 || n == 5 || n == 7)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }

    }

}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int x; 
int main() {
  cin >> x; 
  if (x == 3 || x==5||x==7) puts("YES");
  else puts("NO");
  return 0;
} 


Measured memory_bytes: 3628
K=((N=2*gets.to_i)**0.5).to_i
s=[[]]
t=0
K.times{|i|
	s<<[]
	(0..i).map{|j|
		s[i+1][j]=s[j][i]=t+=1
	}
}
puts K*-~K==N ? [:Yes,K+1,s.map{|s|[K,*s]}]: :No


Measured memory_bytes: 8316
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
	int n;
	string s;
	cin>>n>>s;
	
	for(int i=0; i<s.size(); i++)
	{
		if(s[i]==s[i-1]) n--;
	}
	
	cout<<n;
	return 0;
}

Measured memory_bytes: 3732
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int MAX = 1e5 + 10;
int n, m, mx, dis[MAX];
bool mark[MAX];
vector <int> adj[MAX];

int dfs (int v){
	mark[v] = true;
	for (auto u : adj[v]){
		if (!mark[u]){
			dfs(u);
		}
	}
	int MX = 0;
	for (auto u : adj[v]){
		MX = max (dis[u], MX);
	}
	dis[v] = max (dis[v], MX + 1);
	mx = max (dis[v], mx);
}

main (){
	cin >> n >> m;
	for (int i = 0 ; i < m ; i++){
		int u, v;
		cin >> u >> v;
		adj[--u].pb(--v);
	}
	for (int i = 0 ; i < n ; i++)
		if (!mark[i])
			dfs(i);
	cout << mx - 1;
}

Measured memory_bytes: 8704
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n) {
        if (s.substr(i,3)=="ABC") {
            ++ans;
            i += 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

n = Ii()
a = sorted(Li(),reverse=True)
ans = a.pop(0)
for i in range(n//2-1):
  ans += 2*a[i]
  
if n%2 == 1:
  ans += a[i+1]  
  
print(ans)

Measured memory_bytes: 31296
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int w,h;
		cin>>w>>h;
		if(h==0) break;
		vs a(h);
		for(auto &i:a) cin>>i;
		vi x(100,-1),y(100,-1);
		int id=1;
		for(int i=0;i<h;i++) for(int j=0;j<w;j++){
			if(a[i][j]=='o') x[0]=i,y[0]=j;
			if(a[i][j]=='*'){
				x[id]=i,y[id]=j;
				id++;
			}
		}
		vvi g(id,vi(id));
		for(int i=0;i<id;i++){
			queue<pip> q;
			q.push({0,{x[i],y[i]}});
			vvi b(h,vi(w,inf));
			b[x[i]][y[i]]=0;
			while(!q.empty()){
				pip p=q.front();q.pop();
				int sx=p.second.first,sy=p.second.second;
				for(int k=0;k<4;k++){
					int cx=sx+dx[k],cy=sy+dy[k];
					if(cx>=0&&cx<h&&cy>=0&&cy<w&&a[cx][cy]!='x'&&b[cx][cy]==inf){
						b[cx][cy]=p.first+1;
						q.push({p.first+1,{cx,cy}});
					}
				}
			}
			for(int j=0;j<id;j++) g[i][j]=b[x[j]][y[j]];
		}
		int n=id;
		vvi dp(1<<n,vi(n,inf));
		dp[0][0]=0;
		for(int i=0;i<1<<n;i++) for(int j=0;j<n;j++) if(dp[i][j]<inf){
			for(int k=0;k<n;k++) if(!(i&1<<k)){
				dp[i+(1<<k)][k]=min(dp[i+(1<<k)][k],dp[i][j]+g[j][k]);
			}
		}
		int res=inf;
		for(int i=1;i<n;i++) res=min(res,dp.back()[i]);
		if(res==inf) res=-1;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3284
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int X,N;
int cnt[102];

int main(){
    cin>>X>>N;
    rep(i,N){
        int p;
        cin>>p;
        cnt[p]++;
    }

    int dis=X;
    int ans=0;
    rep(i,102){
        if(cnt[i]==0){
            if(abs(i-X)<dis){
                dis=abs(i-X);
                ans=i;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#define MAX_ELEM 200

template <class X>
class Stack {
  public:
    void push(X elem) {
      Box[pos++] = elem;
    }
    X pop(void) {
      return Box[--pos];
    }
  private:
    X Box[MAX_ELEM];
    unsigned int pos = 0;
};

int main() {
  Stack<int> stack;
  std::string token;
  
  while (std::getline(std::cin, token, ' ')) {
    if (token[0] == '+' || token[0] == '-' || token[0] == '*') {
      auto rhs = stack.pop();
      auto lhs = stack.pop();
      auto result = token[0] == '+' ? lhs + rhs
                  : token[0] == '-' ? lhs - rhs
                  : lhs * rhs;
      stack.push(result);
    } else {
      stack.push(std::stoi(token));
    }
  }
  std::cout << stack.pop() << std::endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Og")
#pragma GCC push_options
#pragma GCC pop_options
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char s;
    cin >> s;
    cout << char(s + 1);
}

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

int main() {
    int A , B ;
    cin >> A >> B ; // 1 ≤ A,B ≤ 100
    if (B*2 < A) cout << A - 2*B << endl ;
    if (B*2 >= A) cout << "0" << endl ;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define reps2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

char n[200000 + 1];
int num[200000 + 1];
int t[200000 + 1], bin[2020];
const int M = 2019;

ll mod_power(ll x, ll n, ll M) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_power((x * x) % M, n / 2, M);
    } else {
        return (mod_power((x * x) % M, n / 2, M) * x) % M;
    }
}

int main() {
    cin >> n;
    int len = strlen(n);
    rep(i, len) { num[i] = n[i] - '0'; }
    rrep(i, len) {
        t[i] = (t[i + 1] + mod_power(10, len - i - 1, M) * num[i]) % M;
        bin[t[i]]++;
    }
    ll ans = 0;
    bin[0]++;
    rep(i, M) { ans += bin[i] * (bin[i] - 1) / 2; }

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

Measured memory_bytes: 5336
#include<stdio.h>
using namespace std;
int p[10010];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int s;
    scanf("%d",&s);
    int a;
    int statu=0;
    for(int i=1;i<=s;i++)
    {
        scanf("%d",&a);
        for(int j=0;j<a;j++,statu++)
            p[statu]=i;
    }
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            for(int j=0;j<m-1;j++)
            printf("%d ",p[i*m+j]);
            printf("%d\n",p[(i+1)*m-1]);
        }
        else
        {
            for(int j=m-1;j>0;j--)
                printf("%d ",p[i*m+j]);
            printf("%d\n",p[i*m]);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
signed main(){
    int a,b;
    cin>>a>>b;
    int l=gcd(a,b);
    set<int> s;
    int c=2;
    while(1){
        if(c>1000000)break;
        if(l%c==0){
            l/=c;
            s.insert(c);
        }else{
            c++;
        }
    }
    if(l!=1)s.insert(l);
    cout<<1+s.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

template <typename T>
vll factorization(T n){
  vll v;
  ull MAX=(ull)sqrt(n)+1;
  for(ull i=2;i<MAX;++i) while(n%i==0) {
      v.pb(i);
      n/=i;
  }
  if(n!=1) v.pb(n);
  return v;
}

void solve() {
  // main coding
  ull a,b;
  cin>>a>>b;
  ull g=gcd(a,b);
  vll v=factorization(g);
  v.erase(unique(v.begin(),v.end()),v.end());
  cout<<v.size()+1<<endl;
}

int main() {
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
void swp(int &a, int &b) {
	if (a > b) {
		int hoge = a;
		a = b;
		b = hoge;
	}
}
int main()
{
	int input[2];
	input[0] = 1;
	input[1] = 1;
	while(1){
		cin >> input[0] >> input[1];
		if (input[0] + input[1] == 0)break;
		swp(input[0], input[1]);
		cout << input[0] << " " << input[1] << endl;
	}
}


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

char masu[55][55];
ll moves[55][55];
ll H , W;

void M(int h, int w, int deepth){
  if(h >=H || w >=W) return;
  if(h<0 || w < 0)return;
  if(masu[h][w] != '.')return;
  //if(moves[h][w] < deepth && moves[h][w]!=0) return;
  if(moves[h][w] > deepth || moves[h][w]==0){
    moves[h][w] = deepth;
    M(h+1,w,deepth+1);
    M(h-1,w,deepth+1);
    M(h,w+1,deepth+1);
    M(h,w-1,deepth+1);
  }
}

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

  cin >> H >> W;
  ll d=0, s=0;//dot, sharpe
  rep(i,H){
    string inp; cin >> inp;
    rep(j,W){
      masu[i][j] = inp[j];
      if(inp[j]=='#')s++;
      else d++;
    }
  }

  M(0,0,1);


  if(moves[H-1][W-1] == 0)
    cout << "-1" << endl;
  else
    cout << d-moves[H-1][W-1]<< endl;;
  
  

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int solve(int P, int T) {
	return (int)((double)P * (100.0 + (double)T) / 100.0);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X, Y, S;
	cin >> X >> Y >> S;
	while (X != 0) {
		int ans = 0;
		FOR(s1, 1, S) {
			FOR(s2, 1, S) {
				if (solve(s1,X) + solve(s2,X) != S) continue;
				chmax(ans, solve(s1,Y) + solve(s2,Y));
			}
		}
		cout << ans << endl;
		cin >> X >> Y >> S;
	}
	return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 200010;

int N;
string X_s;
vector<int> X;

// [0]: 2^i % (x_cnt - 1)
// [1]: 2^i % (x_cnt + 1)
int pow2[2][MAX_N];

// f(n) 
int func(int n) {
    int cur = n;
    int ret = 0;
    while(cur > 0) {
        int cnt = __builtin_popcountll(cur);
        cur %= cnt;
        ret++;
    }
    return ret;
}

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

    cin >> N >> X_s;
    X.resize(N);

    // X の立っているビットの数
    int x_cnt = 0;
    REP(i, N) {
        X[i] = X_s[i] - '0';
        if(X[i] == 1) { x_cnt++; }
    }

    // pow2 の作成
    int mod = x_cnt - 1;
    if(mod > 1) {
        pow2[0][0] = 1;
        for(int i = 1; i < N; ++i) {
            pow2[0][i] = pow2[0][i-1] * 2;
            pow2[0][i] %= mod;
        }
    }

    mod = x_cnt + 1;
    pow2[1][0] = 1 % mod;
    for(int i = 1; i < N; ++i) {
        pow2[1][i] = pow2[1][i-1] * 2;
        pow2[1][i] %= mod;
    }

    // X の各ビット全ての剰余を足したもの
    int x_bit_sum[2] = {};
    reverse(X.begin(), X.end());
    REP(i, N) {
        if(X[i] == 1) {
            x_bit_sum[0] += pow2[0][i];
            x_bit_sum[1] += pow2[1][i];
        }
    }

    reverse(X.begin(), X.end());
    REP(i, N) {
        int ans;
        if(X[i] == 0) {
            // ビットが増える
            int val = x_bit_sum[1] + pow2[1][N - 1 - i];
            int mod = x_cnt + 1;
            val %= mod;
            ans = func(val) + 1;
        }
        else {
            // ビットが減る
            if(x_cnt > 1) {
                int val = x_bit_sum[0] - pow2[0][N - 1 - i];
                int mod = x_cnt - 1;
                val %= mod;
                ans = func(val) + 1;
            }
            else {
                ans = 0;
            }
        }
        printf("%lld\n", ans);
    }

    return 0;
}



Measured memory_bytes: 8340
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;

// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

     ll n;
     cin>>n;
     int cnt=0;
     while(n>0)
	 {
	 	 n=n/2;
	 	 cnt++;
	 }
	// deb(cnt);
	 ll ans=0;
	 ll open=1;
	 for(int i=0;i<cnt;i++)
	 {
	 	  ans=ans+open;
	 	  open=open*2;
	 }
	 cout << ans;


}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int d;
    cin>>d;
    vector<int> c(26);
    rep(i,26)cin>>c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d)rep(j,26)cin>>s[i][j];
    /*
    vector<int> t(d);
    rep(i,d)cin>>t[i];
    */

    vector<int> last(26,0);
    ll score=0;
    rep(i,d){
        ll mm=0;
        int ind;
        rep(j,26){
            int m=s[i][j];
            last[j]=i+1;
            ll sc=0;
            sc+=m;
            rep(k,26){
                sc-=(c[k]*(i+1-last[k]));
            }
            if(sc>=mm)ind=j+1;
            mm=max(sc,mm);
            last[j]=0;
        }
        cout<<ind<<endl;
        last[ind-1]=i+1;
        score+=mm;
        
    }
    score=max(1000000+score,(ll)0);
    //cout<<score<<endl;
            


}

Measured memory_bytes: 3680
package main

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

func main() {
	var n, p int
	fmt.Scan(&n)
	fmt.Scan(&p)

	var max int

	reader := bufio.NewScanner(os.Stdin)

	dan := make([][]string, n, n)
	l, r, d, t := [2000][2000]int{}, [2000][2000]int{}, [2000][2000]int{}, [2000][2000]int{}
	for i := 0; i < n; i++ {
		reader.Scan()
		dan[i] = strings.Split(reader.Text(), "")
	}

	wg := &sync.WaitGroup{}

	wg.Add(1)
	go func() {
		for i := 0; i < n; i++ {
			for j := 0; j < p; j++ {
				if dan[i][j] == "#" {
					d[i][j] = 0
				} else {
					if i == 0 {
						d[i][j] = 1
					} else {
						d[i][j] = d[i-1][j] + 1
					}
				}
			}
		}
		wg.Done()
	}()

	wg.Add(1)
	go func() {
		for i := 0; i < n; i++ {
			for j := 0; j < p; j++ {
				if dan[i][j] == "#" {
					l[i][j] = 0
				} else {
					if j == 0 {
						l[i][j] = 1
					} else {
						l[i][j] = l[i][j-1] + 1
					}
				}
			}
		}
		wg.Done()
	}()

	wg.Add(1)
	go func() {
		nn := n - 1
		pp := p - 1
		for i := nn; i >= 0; i-- {
			for j := pp; j >= 0; j-- {
				if dan[i][j] == "#" {
					r[i][j] = 0
				} else {
					if j == pp {
						r[i][j] = 1
					} else {
						r[i][j] = r[i][j+1] + 1
					}
				}
			}
		}
		wg.Done()
	}()

	wg.Add(1)
	go func() {
		nn := n - 1
		pp := p - 1
		for i := nn; i >= 0; i-- {
			for j := pp; j >= 0; j-- {
				if dan[i][j] == "#" {
					t[i][j] = 0
				} else {
					if i == nn {
						t[i][j] = 1
					} else {
						t[i][j] = t[i+1][j] + 1
					}
				}
			}
		}
		wg.Done()
	}()

	wg.Wait()
	for i := 0; i < n; i++ {
		for j := 0; j < p; j++ {
			if dan[i][j] != "#" {
				v := l[i][j] + r[i][j] + t[i][j] + d[i][j] - 3
				if v > max {
					max = v
				}
			}
		}
	}

	fmt.Printf("%#v\n", max)
}


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

int main() {
    int a, b;
    double c, s, l, h;
    cin>>a>>b>>c;
    c = c * 2 * M_PI / 360;
    s = 0.5 * a * b * sin(c);
    l = a + b + sqrt(a*a + b*b - 2*a*b*cos(c));
    h = b*sin(c);
    printf("%.5f\n%.5f\n%.5f\n", s, l, h);
    return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int n_max=100000;
long long inf=1000000000000000000;
int main()
{
    int n,i;
    long long res=1;
    long long a[n_max];
    double m=inf;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>0)
            m/=a[i];
    }
    sort(a,a+n);
    if(a[0]==0)
    {
        res=0;
    }
    else if(m<0.2)
    {
        res=-1;
    }
    else
    {
        for(int i=0;i<n;i++)
            res*=a[i];
        if(res>inf)
            res=-1;
    }
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, char> P;
typedef long long ll;
const int INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};

int main()
{
	int n, m;
	cin >> n >> m;
	REP(i, n)
	{
		if (i < (n-1) / 2) cout << 0;
		else cout << m;
		cout << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  map<pair<string,string>, int> mp;
  FOR(i, 0, 1LL<<n) {
    string a = "", b = "";
    REP(j, n) {
      if(i&1<<j) {
        a += s[j];
      } else {
        b += s[j];
      }
    }
    mp[{a, b}]++;
  }

  int ret = 0;
  FOR(i, 0, 1LL<<n) {
    string a = "", b = "";
    REP(j, n) {
      if(i&1<<j) {
        a += s[j+n];
      } else {
        b += s[j+n];
      }
    }
    reverse(ALL(a));
    reverse(ALL(b));
    ret += mp[{b, a}];
    // cout << a << " " << b << endl;
    // cout << ret << endl;
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 87040
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

using namespace std;

ll dp[2001][2001]={};
int main(){
    int N,M;
    cin >> N >> M;
    int S[2000], T[2000];
    for(int i=0; i<N; i++){
        cin >> S[i];
    }
    for(int i=0; i<M; i++){
        cin >> T[i];
    }
    
    for(int i=0; i<=N; i++){
        dp[i][0]=1;
    }
    for(int j=0; j<=M; j++){
        dp[0][j]=1;
    }
    for(int i=1; i<=N; i++){
        for(int j=1; j<=M; j++){
            if(S[i-1]==T[j-1]){
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            }else{
                dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
            }
            dp[i][j]%=MOD;
            dp[i][j]+=MOD;
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[N][M]<<endl;
    return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n;cin>>n;
    ll u[n],v[n];rep(i,0,n-2)cin>>u[i]>>v[i];
    ll sum=(n*(n+1)*(n+2))/6;
    rep(i,0,n-2){
        if(u[i]>v[i]){
            ll c=v[i];
            v[i]=u[i];
            u[i]=c;
        }
        sum-=(u[i]*(n+1-v[i]));
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 6776
#include<iostream>
using namespace std;
long long b[100000];
int main(){
	long long pos=1000000000000000000;
	int a;
	cin>>a;
	long long ans=1;
	for(int i=1;i<=a;i++){
		cin>>b[i];
		if(b[i]==0){
		
		cout<<"0"<<endl;
		return 0;}
	
	
}

 for(int i=1;i<=a;i++){
	  if(b[i]<=pos/ans){
	  	ans=ans*b[i];
	  }
	  else {cout<<"-1";
	  return 0;
	  }
}cout<<ans<<endl;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
/*
 *  GUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
int n,w;
ll dp[101][100001];
vector<pair<int,int>> v;
ll sol(int i, int w){
    if(w<0){
        return -1e12;
    }
    if(i == n || w==0)
        return 0;
    ll &ret = dp[i][w];
    if(~ret)
        return ret;
    return ret=max(sol(i+1,w),v[i].second+sol(i+1,w-v[i].first));
}
int main() {
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    ///freopen("output.txt", "w", stdout);
#endif*/
    run();
    cin >> n >> w;
    v.resize(n);
    for (auto &i:v) {
        cin >> i.first >> i.second;
    }
    memset(dp, -1, sizeof(dp));
    cout << sol(0, w) << endl;
    return 0;
}


Measured memory_bytes: 79232
#include <stdio.h>

#define N 44

int fibonacci(int);

  int f[N];


int main(){

  int n,f;


  scanf("%d",&n);

  f=fibonacci(n);


  printf("%d\n",f);

  return 0;
}


int fibonacci(int x){

  int i;

  f[0]=1;
  f[1]=1;

  for(i=2;i<=x;i++) f[i]=f[i-2]+f[i-1];

  return f[x];

}

Measured memory_bytes: 596