akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            bool end = true;
            while (end)
            {

                string[] input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                string op = input[1];
                int b = int.Parse(input[2]);

                switch (op)
                {
                    case "+":
                        Console.WriteLine(a + b);
                        break;

                    case "-":
                        Console.WriteLine(a - b);
                        break;

                    case "/":
                        Console.WriteLine(a / b);
                        break;

                    case "*":
                        Console.WriteLine(a * b);
                        break;

                    case "?":
                        end = false;
                        break;

                }

            }
        }
    }
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

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

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

  


int main(){ 
  //int a, b;
  string s, t;
  cin >> s >> t;
  int sz = s.size();
  int sz_t = t.size();
  int ch = 0;
  rep(i, sz){
    if(s.at(i)!=t.at(i)){
      cout << "No" << endl;
      ch = 1;
      break;
    }
  }
  if(ch==0){
      
    //if(sz+1!=sz_t) cout << "No" << endl;
    cout << "Yes" << endl;
  }
}

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

int calc(int x, int y, int z, int k){
    int res = 0;
    if(k & 1) res += x;
    else res -= x;
    if(k & 2) res += y;
    else res -= y;
    if(k & 4) res += z;
    else res -= z;
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> x(n), y(n), z(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    int ans = 0;
    for(int k = 0; k < (1<<3); k++){
        vector<int> d(n);
        for(int i = 0; i < n; i++){
            d[i] = calc(x[i], y[i], z[i], k);
        }
        sort(d.rbegin(), d.rend());
        int sum = 0;
        for(int i = 0; i < m; i++){
            sum += d[i];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string x[105]; //入力用
	string y[205]; //出力用
	int h,w;
	int i=0;
	
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>x[i];
	}
	for(i=0;i<h;i++){
		y[2*i]=x[i];
		y[2*i+1]=x[i];
	}
	for(i=0;i<h*2;i++){
		cout<<y[i]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
a = input()
aSplit = a.split(' ')
A = int(aSplit[0])
B = int(aSplit[1])
C = int(aSplit[2])
# a[0] = int(input())
# a[1] = int(input())
# a[2] = int(input())
if(C<=A and C>=B):
    print("Yes")
elif(C<=B and C>=A):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import sys
from collections import Counter
import math

N = int(sys.stdin.readline())
s_list = ["".join(sorted(list(sys.stdin.readline().rstrip()))) for x in range(N)]
s_list = Counter(s_list)
count = 0
for i in s_list.values():
    if i == 1:
        continue
    count += (math.factorial(i) // math.factorial(i - 2)) // math.factorial(2)
print(count)


Measured memory_bytes: 19728
import java.util.*;
public class Main {
	public static void main(String[] args){
    //データ取り込み
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
		if(A+B>=C){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
(let* ((n (read))
       (m (read))
       (lst (loop repeat m
                  collect (cons (read) (read))))
       (ans (loop repeat n
                  collect 0)))

  (loop for i in lst
        do (progn (incf (nth (1- (car i)) ans))
                  (incf (nth (1- (cdr i)) ans))))

  (format t "~{~A~%~}" ans))


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

int main() {
  ll n;
  cin >> n;
  ll ans = n * (n-1) / 2;
  cout << ans << endl;
  return 0;
}

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

man=1
cnt=0
man_list=[0]*N

A.sort()
A += [0]

for a in A:
  if a != man:
    man_list[man-1] = cnt
    man = a
    cnt=0
  cnt+=1

print(*man_list)

Measured memory_bytes: 32372
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#define ull unsigned long long
#define rep(N) for(int i=0;i<N;i++)
#define repj(J) for(int j=0;j<J;j++)
using namespace std;
set <int> a1;

int main()
{
//	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	int x;
	vector <int> vec;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		if(a1.count(x))
		{
			vec.push_back(x);
			a1.erase(x);
		}
		else
		{
			a1.insert(x);
		}
	}
	ull s,max=0;
//	rep(vec.size())
//	{
//		cout<<vec[i]<<endl;
//	}
	int len=vec.size();
	rep(len)
	{
		for(int j=i;j<len;j++)
		{
			if(j==i) continue;
			s=(ull)vec[i]*(ull)vec[j];
//			cout<<(ull)vec[i]*(ull)vec[j]<<endl;
			if(s>max) max=s;
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define F first
#define S second
#define MP make_pair
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string s;

int main()
{jizz
	ll ans=0,t=0;
	cin >> s;
	for(int i=0;i<s.size();++i)
		if(s[i]=='W')
			ans+=i-t,++t;
	cout << ans << "\n";
}

Measured memory_bytes: 720
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from collections import defaultdict

n, m = list(map(int, input().split()))
d = defaultdict(set)
ps = set()
p = []
y = []
for i in range(m):
    pi, yi = list(map(int, input().split()))
    p.append(pi)
    y.append(yi)
    ps.add(pi)
    d[pi].add(yi)

dn = defaultdict(list)
for i in d.keys():
    n = 1
    for j in sorted(d[i]):
        dn[i, j] = n
        n += 1

for i in range(len(p)):
    print('{0:06d}'.format(p[i]), '{0:06d}'.format(dn[p[i], y[i]]), sep='')


Measured memory_bytes: 63872
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[200003];
ll n,m;
bool vis[1009][1009];
struct threeElements{
int _1st,_2nd,_3rd;
};
int read(){int x;cin>>x;return x;}
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
  string s;
  cin>>s;
  int ans=0,c=0;
  for(int i=0;i<s.length();i++)
  {
      if(s[i]=='R')
        c++;
      else
      {
         ans=max(c,ans);
         c=0;
      }
  }
    cout<<max(ans,c);
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A,A+N);
  cout << A[N-1] - A[0] << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll A;
    
    cin >> A;

    ll ans = A * (A + 1) / 2;

    cout << ans << endl;


    // if(ans){
    //     cout << "Yes" << endl;
    // }else{
    //     cout << "No" << endl;
    // }

}


Measured memory_bytes: 768
#include <iostream>
#include<algorithm>
 
using namespace std;
 
 
 
int main()
{
    unsigned long long a;
  
    cin >> a;
    int output = 0;
  unsigned long long xxx;
  xxx=a;
    if (a == 1) {
        cout << 0;
        return 0;
    }
    unsigned long long b;
    b = sqrt(a);
    for (int i = 2; i < a; i++) {
      if(i==b){
        break;
      }
        if (a % i == 0) {
            int count = 1;
            while (a != 1) {
                bool right = true;
                for (int j = 0; j < count; j++) {
                    if (a % i == 0) {
                        a = a / i;
                    }
                    else {
                        right = false;
                        break;
                    }
                }
                if (right) {
                    output++;
                }
                else {
                    break;
                }
                count++;
            }
        }
        if (a == 1) {
            break;
        }
      
    }
    if (a!=1)output++;
    cout << output;
 
 
    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b


signed main(){
	int n; cin>>n;
	int a,b; cin>>a>>b;
	vl vec(n);
	rep(i,0,n)cin>>vec[i];
	sort(all(vec));
	int i=upper_bound(all(vec),a)-vec.begin();
	int j=vec.end()-lower_bound(all(vec),b+1);
	cout<<min({n-i-j,i,j})<<endl;
	
	return 0;
}

Measured memory_bytes: 3552
#pragma region 
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<string>
typedef long long ll;
template <typename T>void read(T &x){x=0;char ch=getchar();ll f=1;while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}x*=f;}
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
#pragma endregion
ll poww(ll a) {
    return a * a * a * a * a;
}
int main() {
    IO;
    ll x;
    cin >> x;
    for (ll i = 0; i <= 2000;++i) {
        ll tag = poww(i) - x;
        ll l = -3000, r = 3000;
        while (l<=r) {
            ll mid = (l + r) >> 1;
            ll t = poww(mid);
            if (t==tag) {
                cout << i << " " << mid << endl;
                return 0;
            }
            else if (t<tag)
                l = mid + 1;
            else
                r = mid - 1;
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    pair<pair<string, int>, int> a[n];

    for(int i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        a[i] = make_pair(make_pair(s, -p), i + 1);
    }

    sort(a, a + n);
    for(int i = 0; i < n; i++) cout << a[i].second << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 20

int moun[N]={};

int main(void)
{ 
    
    int n,i,j,c=0,mounmax=0;
 scanf("%d",&n);
    
for (i=0;i<n;i++){ 
    scanf("%d",&moun[i]);}
    
for(i=0;i<n;i++){
        if(moun[i]>=mounmax){c++; mounmax=moun[i];}
}
   
printf("%d\n",c);
}

Measured memory_bytes: 128
from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n)]
data = []
for i in range(m):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
    data.append([a - 1, b - 1])

ans = 0

def dfs(queue, a, b):
    while len(queue) != 0:
        x = queue.popleft()
        for i in range(len(graph[x])):
            if (min(graph[x][i], x) != a or max(x, graph[x][i]) != b) and visited[graph[x][i]] == 0:
                queue.append(graph[x][i])
                visited[graph[x][i]] = 1

for i in range(m):
    visited = [0] * n
    visited[0] = 1
    queue = deque()
    queue.append(0)
    dfs(queue, data[i][0], data[i][1])
    if sum(visited) != n:
        ans += 1

print(ans)

Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 1e2 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;

ll a[3][110],suml[3][110],sumr[3][110];

int main()
{
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    mst(suml,0);
    mst(sumr,0);
    int n;
    scanf("%d",&n);
    for(int i=1; i<=2; i++)
        for(int j=1; j<=n; j++) {
            scanf("%lld",&a[i][j]);
            suml[i][j] = suml[i][j-1] + a[i][j];
        }
    for(int i=1; i<=2; i++)
        for(int j=n; j>=1; j--)
            sumr[i][j] = sumr[i][j+1] + a[i][j];
    ll ans = 0;
    for(int i=1; i<=n; i++) {
        ll sum = suml[1][i-1] + sumr[2][i+1] + a[1][i] + a[2][i];
        ans = max(ans,sum);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let cs = Array.init n @@ fun _ -> Scanf.scanf "%c" Fun.id in
  let reds = Array.make (n + 1) 0 in (* th以上の赤 *)
  let whites = Array.make (n + 1) 0 in (* th未満の白 *)
  for i = 0 to n - 1 do
    match cs.(i) with
    | 'R' -> reds.(i) <- reds.(i) + 1
    | 'W' -> whites.(i + 1) <- whites.(i + 1) + 1
  done;
  for i = n - 1 downto 0 do
    reds.(i) <- reds.(i) + reds.(i + 1)
  done;
  for i = 0 to n - 1 do
    whites.(i + 1) <- whites.(i) + whites.(i + 1)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left min max_int @@
  Array.init (n + 1) @@ fun i -> max reds.(i) whites.(i)

Measured memory_bytes: 12292
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	string in = "";
	while (getline (cin, in ) && in != "." ){
		stack<char> kakko;
		bool ok = true;
		rep (i, in.size() ){
			if (in[i] == '[' || in[i] == '(' ){
				kakko.push(in[i] );
			}else
			if (in[i] == ']' ){
				if (!kakko.empty() && kakko.top() == '[' ){
					kakko.pop();
				}else{
					ok = false;
				} // end if
			}else
			if (in[i] == ')' ){
				if (!kakko.empty() && kakko.top() == '(' ){
					kakko.pop();
				}else{
					ok = false;
				} // end if
			} // end if
		} // end rep

		if (!kakko.empty() ) ok = false;

		if (ok ){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		} // end if

	} // end while	
		
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	n=log2(n);
	printf("%lld",1LL<<n);
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <list>
#include <chrono>
#include <fstream>
#include <ctime>
#include <random>

using namespace std;
using namespace std::chrono;

const int mod = int(1e9) + 7;
//const int SZ = 10100;
//const int MX = 210500;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
#define ll long long
#define sqr(x) (x)*(x)
#define FREIN(file) freopen(file, "rt", stdin)

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)

const int magic = 3;

void solve();
//void init();

void dump(const vector<int>& a) {
    for (int i = 0; i < a.size(); i++) {
        cerr << a[i] << ' ';
    }
    cerr << endl;
}

int main(int argc, char** argv)
{
#ifdef LOCAL
    freopen("../in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
//    cin >> t;
//    init();
    while(t--){
        solve();
    }
    return 0;
}
// Solution ***********************************************************************************************

const int MX = 100500;


void solve() {
    int n, m;
    cin >> n >> m;
    if (n > m) {
        swap(n, m);
    }
    if (n == 1 && m == 1) {
        cout << "1\n";
        return;
    }
    if (n == 1) {
        cout << m - 2 << "\n";
        return;
    }
    long long ans = n - 2;
    cout << ans * (m - 2) << endl;
}


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

int main()
{
	double a,b,c;
	cin >> a >> b >> c;
	c = (acos(-1.0)*c)/180.0;
	double s = a*b*sin(c)/2.0;
	double l = a + b + sqrt(a*a + b*b - 2*a*b*cos(c));
	double h = b*sin(c);

	cout << fixed;
	cout.precision(6);
	cout << s << endl << l << endl << h << endl;
	return 0;
}

Measured memory_bytes: 1308
import itertools

N,M = (int(i) for i in input().split()) 
ks = [[int(i) for i in input().split()] for i in range(M)]
p = list(map(int, input().split()))

for i in ks:
	i.pop(0)
	
ans=0

for light in itertools.product([0,1], repeat=N):
	ok=True
	for _index, _list in enumerate(ks):
		_sum=0
		for s in _list:
			_sum += light[s-1]
		if _sum%2 != p[_index]:
			ok=False
			break
	if ok is True:
		ans+=1

print(ans)

Measured memory_bytes: 3064
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    ans = 0
    for i,s in enumerate(S):
        if s!=S[-i-1]:
            ans += 1
    print(ans//2)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[30]; //食べ物の種類は最大30種類
        int ans = 0;
        
        //食べ物iを好きと答えた人数を種類毎A[i]にカウント
        for(int i = 0; i < N; i++){
            int K = sc.nextInt();
            
            for(int j = 0; j < K; j++){
                A[sc.nextInt() - 1]++;
            }
        }
        
        //N人全てが好きと答えた食べ物の種類数をansでカウント
        for(int i = 0; i < 30; i++){
            if(A[i] == N)ans++;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

pub fn digit_num(mut n: u64, d: u64) -> u64 {
    let mut k = 0;
    while n != 0 {
        k += 1;
        n /= d;
    }
    k
}

fn main() {
    input! {
        n: u64,
        k: u64
    }
    println!("{}", digit_num(n,k));
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <queue>
#include <stack>
#include<fstream>
#include<algorithm>
#include<set>
#include<map>
using namespace std;

int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c;
	return 0;



 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int test = 1;
    // cin >> test;
    while(test--) {
        int res = 0;
        int n;
        cin >> n;
        int a[n];
        for(int i=0;i<n;i++) {
            cin >> a[i];
        }
        for(int i=0;i<n;i++) {
            for(int j=i+1;j<n;j++) {
                for(int k=j+1;k<n;k++) {
                    if((a[i]+a[j])>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i]) {
                        // cout << "I : J : K  " << i+1 << " " << j+1 << " " << k+1 << endl;
                        res++;
                    }
                }
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18


void solve()
{
   char arr[130];
   for(int i=97;i<=122;i++) arr[i-96]=i;
   lll n;
   cin>>n;
   vector<int>v;
   while(1)
   {
       int Mod=n%26;
       //cout<<"Mod : "<<Mod<<endl;
       if(Mod==0) { v.push_back(26); n-=26; n/=26; }
       else { v.push_back(Mod); n-=Mod; n/=26; }
       //cout<<"N : "<<n<<endl;
       if(n<=0) break;
   }
   reverse(v.begin(),v.end());
   for(int i=0;i<v.size();i++)
   {
       cout<<arr[v[i]];
   }
   cout<<endl;
}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //int t; cin>>t; while(t--) solve();
    solve();

}


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

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define fr(i,n) for(i=1;i<=n;i++)

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

ll a[1100];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,cnt=0;
    cin>>n;
    fr(i,n) cin>>a[i];
    for(i=2;i<=n;i++)
        if(a[i]==a[i-1]) a[i]=-1, cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cins3(int, n, c, s, f);
    
    For(i, n){
        int t = 0;
        for(int j = i; j < n-1; j ++){
            t = max(s[j], (t+f[j]-1)/f[j]*f[j]);
            t += c[j];
        }
        Cout(t);
    }
}


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

using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
double eps = 1e-1;

void solved()
{   
    double a,b;
    cin >> a >> b;
    double ta = a,tb = b;
    for(int i = 1;i <= 10000;i++)
    {
        ta = i* 0.08,tb = i*0.1;
        if(floor(ta) == a && floor(tb) == b)
        {
            cout << i;
            return;
        }
    }
    cout << -1;
}


int main()
{
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#endif 
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solved();
    }

#ifdef LOCAL
    system("pause");
#endif 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

        vector<ll> S(3 * N + 1), T(N + 1, 0);

        rep(i, 3 * N) cin >> S[i];

        sort(S.begin(), S.begin() + 3 * N);
        reverse(S.begin(), S.begin() + 3 * N);
        ll ans = 0;

        for (int i = 1; i < 2 * N + 1; i += 2)
        {
                ans += S[i];
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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; }

int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,0,n){
        cin>>a[i];
    }
    ll all_xor=a[0];
    rep(i,1,n){
        all_xor = (all_xor ^ a[i]); 
    }
    rep(i,0,n){
        if(i==n-1) cout<<(all_xor ^ a[i])<<endl;
        else cout<<(all_xor ^ a[i])<<" ";
    }
}

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

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 = 1ll << 60;

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

int N;
int A, B, C;
int l[10];
int rsl;

void calc(vector<int> v) {
    int tmp = 0;
    int tmp_a = 0, tmp_b = 0, tmp_c = 0;
    bool flag_a = false, flag_b = false, flag_c = false;
    rep(i, 0, v.size()) {
        if(v[i] == 1) {
            if(flag_a) tmp += 10;
            flag_a = true;
            tmp_a += l[i];
        } else if(v[i] == 2) {
            if(flag_b) tmp += 10;
            flag_b = true;
            tmp_b += l[i];
        } else if(v[i] == 3) {
            if(flag_c) tmp += 10;
            flag_c = true;
            tmp_c += l[i];
        }
    }
    if(flag_a and flag_b and flag_c) {
        tmp += abs(A - tmp_a) + abs(B - tmp_b) + abs(C - tmp_c);
        chmin(rsl, tmp);
    }

}

void dfs(int depth, vector<int> v) {
    if(depth == N) calc(v);
    else {
        rep(i, 0, 4) {
            v[depth] = i;
            dfs(depth + 1, v);
        }
    }
}

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

    rsl = 1e9;
    cin >> N >> A >> B >> C;
    rep(i, 0, N) cin >> l[i];

    vector<int> v(N);
    dfs(0, v);
    cout << rsl << endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n;
	double out=0;
	cin>>n;
	while(n--){
		double a;string b;
		cin>>a>>b;
		if(b=="BTC")a*=380000;
		out+=a;
		
	}
	cout<<shosu(9)<<out<<endl;
}


Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 200002;

int n;
int a[MAX];

bool eval(int alpha) {
    stack < pair <int, int> > s;
    for (int i = 1; i < n; i++) {
        if (a[i] <= a[i - 1]) {
            int idx = a[i];
            while (!s.empty() && s.top().first > idx)
                s.pop();
            while (idx >= 1) {
                if (s.empty()) {
                    s.push(make_pair(idx, 2));
                    break;
                } else {
                    if (s.top().first < idx) {
                        s.push(make_pair(idx, 2));
                        break;
                    } else {
                        s.top().second++;
                        if (s.top().second <= alpha) {
                            break;
                        } else {
                            s.pop();
                            idx--;
                        }
                    }
                }
            }
            if (idx < 1)
                return false;
        }
    }
    return true;
}

int main(void) {
	// in = fopen("C.in", "rt");
	
	fscanf(in, "%d", &n);
	for (int i = 0; i < n; i++)
	    fscanf(in, "%d", &a[i]);
	
	bool okWithOne = true;
	for (int i = 1; i < n; i++)
	    if (a[i] <= a[i - 1]) okWithOne = false;
	if (okWithOne) {
	    fprintf(out, "1\n");
	    return 0;
    }
	
	int left = 2, right = n;
	while (left <= right) {
	    int mid = (left + right) / 2;
	    eval(mid) ? right = mid - 1 : left = mid + 1;
    }
    fprintf(out, "%d\n", right + 1);
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vpii=vector<pair<int,int>>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vin a(n);
    rep(i,n)cin>>a[i];
    vpii b(n);
    rep(i,n){
        b[i]=make_pair(a[i],i+1);
    }
    sort(all(b));
    rep(i,n-1){
        cout<<b[i].second<<" ";
    }
    cout<<b[n-1].second<<endl;
}

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

typedef long long int ll;

double dp[3001][3001];
double p[3001];

int main()
{
	ios::sync_with_stdio(0);
	ll n;
	cin >> n;
	ll i,j,k;
	for(i=1;i<=n;i++)	
		cin >> p[i];
	double ans=0;
	for(i=0;i<=n;i++)
	{
		dp[0][i]=0;
	}
	for(i=1;i<=n;i++)
	{
		for(k=i+1;k<=n;k++)
			dp[i][k]=0;
	}
	dp[1][0]=(1-p[1]);
	dp[1][1]=p[1];
	for(i=2;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0]*(1-p[i]);
	}
	for(i=2;i<=n;i++)
	{
		for(j=1;j<=i;j++)
		{
			dp[i][j] = p[i]*(dp[i-1][j-1]) + (1-p[i])*(dp[i-1][j]);
		}
	}
	for(k=n/2+1;k<=n;k++)
		ans+=(dp[n][k]);
	cout << fixed << setprecision(10) << ans << "\n";
	return 0;
}

Measured memory_bytes: 70656
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

int main(){
	int n;
	cin>>n;
	REP(i,n){
		double x[3],y[3];
		REP(j,3)cin>>x[j]>>y[j];
		double a = y[2]-y[1];
		double b = y[0]-y[1];
		double c = (x[0]-x[2])*0.5;
		double d = x[1]-x[2];
		double e = x[1]-x[0];
		double f = (y[0]-y[2])*0.5;
		double s = (c*e-b*f)/(a*e-b*d);
		double rx = (x[1]+x[2])*0.5+s*(y[2]-y[1]);
		double ry = (y[1]+y[2])*0.5+s*(x[1]-x[2]);
		double r = sqrt(pow(rx-x[0], 2.0)+pow(ry-y[0], 2.0));
		printf("%.3f %.3f %.3f\n", rx, ry,r);
	}
	return 0;
}

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

#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define INT(n) int n;scanf("%d",&n)
#define AI(a,size,n) array<int,size> a;REP(i,n){scanf("%d",&a[i]);}
#define VS(v,n) vector<string> v(n);REP(i,n){cin>>v[i];}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int main(){
  INT(h); INT(w); VS(as, h);
  int r = 0, c = 0, cnt = 0;
  while (r < h && c < w){
    if (as[r][c] == '.'){break;}
    else {as[r][c] = '.';}
    if (c < w - 1 && as[r][c + 1] == '#'){
      c++;
    }
    else if (r < h - 1 && as[r + 1][c] == '#'){
      r++;
    }
  }
  REP(i, h){REP(j, w){if (as[i][j] == '#'){cnt++;}}}
  if (cnt == 0){printf("Possible\n");}
  else{printf("Impossible\n");}
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int main()
{
    int H, W;
    cin >> H >> W;

    REP(i, H){
        REP(j, W){
            cin >> S[i][j];
        }
    }

    int count_max = 0;

    REP(i, H){
        REP(j, W){
            vector<vector<int>> v(21, vector<int>(21, -1));

            int temp_max = 0;

            // もしも壁から始まる場合は飛ばす
            if(S[i][j] == '#') continue;

            // キューを準備
            queue<P> que;
            // 探索の初期値を入れる
            que.push(P(i, j));
            v[i][j] = 0;

            while(true) {
                //　キューが空ならループを抜ける
                if(que.empty()) {
                    // cout << "empty" << endl;
                    break;
                }
                // キューの中身を取り出す
                P p = que.front(); que.pop();
                int y = p.first;
                int x = p.second;
                int s = v[y][x];

                // 4方向へ繰り返す
                REP(k, 4) {
                    int nx = x+dx[k];
                    int ny = y+dy[k];
                    // 移動すると範囲外になったり、#だったり、探索済みだったら終了する
                    if(nx < 0 || nx >= W || ny < 0 || ny >= H
                        || v[ny][nx] != -1 || S[ny][nx] == '#') continue;
                    // 未探索だったら、キューに入れて現在の距離を記録
                    que.push(P(ny, nx));
                    v[ny][nx] = s+1;
                    count_max = max(count_max, s+1);
                    temp_max = max(temp_max, s+1);
                    // cout << "i" << i << ",j:" << j << endl;
                }
            }
            // cout << i << " " << j << " " << temp_max << endl;
        }
    }
    cout << count_max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5 + 10;
int N,pos[MAX];
int main ()
{
    cin >> N;
    for(int i=0;i<N;i++){
        int x;cin>>x;
        pos[x]=i+1;
    }

    ll res = 0;

    multiset<int>positions;

    positions.insert(0);
    positions.insert(0);
    positions.insert(N+1);
    positions.insert(N+1);


    for(int i=N;i>=1;i--){

            ll curr = i;

            positions.insert(pos[curr]);

            auto it_curr = positions.find(pos[curr]);
            auto it_x = prev(it_curr);
            auto it_y = prev(it_x);

            auto it_a = next(it_curr);
            auto it_b = next(it_a);

            int x = *it_x; // first greater element than curr , that is on the left side of curr element
            int y = *it_y; // second greater element than curr , that is on the left side of curr element
            int a = *it_a; // first greater element than curr , that is on the right side of curr element
            int b = *it_b; // second greater element than curr , that is on the right side of curr element

            ll ways =  (a - pos[i])*1LL*(x-y) + (pos[i] - x)*1LL*(b-a);
            res = res + (curr)*ways;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll dp[20005];
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll s,i,j;
	cin>>s;
	dp[0]=1;
	for(i=3;i<=s;i++){
		for(j=i-3;j>=0;j--){
			dp[i]=(dp[i]%mod+dp[j]%mod)%mod;
		}
	}
	cout<<dp[s]<<endl;
//	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DFloorFunction solver = new DFloorFunction();
        solver.solve(1, in, out);
        out.close();
    }

    static class DFloorFunction {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            long b = in.nextLong();
            long n = in.nextLong();
            out.println((Math.min(n, b - 1) * a) / b);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 32588