akhauriyash/Code-Regression huggingface dataset:
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}


int32_t main()
{
    int n=in();
    for(int i=1;i<=9;i++) for(int j=1;j<=9;j++) if(i*j==n) return cout<<"Yes\n",0;
    cout<<"No\n";
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f,N=1007;
char a[N];
int main()
{
    while(~scanf("%s",a))
    {
        int n=0,s=0,w=0,e=0;
        for(int i=0;a[i];i++)
        {
            if(a[i]=='N')
                n++;
            if(a[i]=='W')
                w++;
            if(a[i]=='E')
                e++;
            if(a[i]=='S')
                s++;
        }
        if(((s==0&&n==0)||(s&&n))&&((w&&e)||(w==0&&e==0)))
        {
//            int cnt=max(s,n)+max(w,e);
//            int len=(int)strlen(a);
//            if(cnt<=len)
//                puts("Yes");
//            else
                puts("Yes");
        }
        else puts("No");
    }
}

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

#define int long long
#define INF 9223372036854775807
#define M_PI 3.14159265358979323846
#define double long double

int mod = INF;

int fastPow(int b, int e){int r = 1;while(e){if(e%2 == 1){r*=b;r%=mod;}b*=b;b%=mod;e/=2;}return r;}
int pgcd(int a, int b){ if(a%b == 0) return b; else return pgcd(b, a%b);}
int sign(int a){if(a < 0){ return -1;}if(a == 0) {return 0;}if(a > 0) {return 1;}}
bool isPrime(int a){if(a == 1) {return false;}int f = sqrt(a);for(int i = 2; i<=f; i++){if(a%i == 0){return false;}}return true;}
int toInt(string s){int tot = 0;for(int i = s.size()-1; i >= 0; i--){tot+=((s[i]-'0')%mod)*fastPow(10,i);tot%=mod;}return tot;}
string toString(int a){string s = "";while(a){s = (char)('0'+a%10) + s;a/=10;}return s;}

vector<int> we(109);
vector<int> v(109);
int n, w;
int memo[109][100009];

int dp(int index, int weight){
    if(index == n) return 0;
    if(memo[index][weight] != -1) return memo[index][weight];
    if(weight-we[index] >= 0){
        return memo[index][weight] = max(dp(index+1, weight), dp(index+1, weight-we[index])+v[index]);
    }else{
        return memo[index][weight] = dp(index+1, weight);
    }
}

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

    cin >> n >> w;
    for(int i = 0; i < n; i++){
        cin >> we[i] >> v[i];
    }
    for(int i = 0; i < 109; i++){
        for(int j = 0; j < 100009; j++){
            memo[i][j] = -1;
        }
    }
    cout << dp(0, w) << endl;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll N=in<ll>(),K=in<ll>();
	ll P = N/K;
	N -= P*K;

	out(min(abs(N-K),N));
	return 0;
}


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

int main() {
  int n; std::cin >> n;
  std::vector<int> a(n), b(n), c(n-1);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  for (int i = 0; i < n; ++i) --a[i];
  for (int i = 0; i < n; ++i) std::cin >> b[i];
  for (int i = 0; i < n-1; ++i) std::cin >> c[i];
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += b[a[i]];
    if (i == 0) continue;
    if (a[i] - a[i-1] == 1) sum += c[a[i-1]];
  }
  std::cout << sum << std::endl;
  return 0;
}

Measured memory_bytes: 3564
n = int(input())
 
li = []
dis = 0
 
for i in range(n):
  x, y = map(int,input().split())
  li.append((x, y))
  
for j in range(n):
  for k in range(n):
    dis += ((li[j][0]-li[k][0]) ** 2 + (li[j][1]-li[k][1]) ** 2) ** 0.5
 
print(dis/n)

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

int main(){
  int x; cin>>x;
  int a=0;
  int b=0;
  for (int i=-200; i<200; i++){
    for (int j=-200; j<200; j++){
      if (pow(i,5)-pow(j,5)==x){
        a=i;
        b=j;
      }
    }
  }
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 4064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
priority_queue<P, vector<P>, greater<P> > que[100010];
vector<int> G[100010];
bool used[100010];
bool used2[100010];
P a[100010];
int size = 0;
void dfs(int x) {
    used[x] = true;
    que[size].push({a[x].first, x});
    for(int next: G[x]) {
        if (!used[next]) dfs(next);
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, N) {
        cin >> a[i].first;
        a[i].second = i;
    }
    if (M == N - 1) {
        cout << 0 << endl;
        return 0;
    }
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    rep(i, N) if (!used[i]) {dfs(i); size++;}
    //cout << size << endl;
    int ans = 0;
    rep(i, size) {
        ans += que[i].top().first;
        used2[que[i].top().second] = true;
    }
    int cnt = 0;
    sort(a, a + N);
    int i = 0;
    while(i < N && cnt < size - 2) {
        //cout << a[i].second << " " << !used2[a[i].second] << endl;
        if (!used2[a[i].second]) {ans += a[i].first; cnt++;}
        i++;
    }
    if (cnt != size - 2) {
        cout << "Impossible" << endl;
    } else {
        cout << ans << endl;
    }



    return 0;
}


Measured memory_bytes: 13176
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;
ll mod = 1e9+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}


const double PI=3.14159265358979323846;

int main(){
  int A, B;
  cin >> A >> B;
  if(A<10 && B<10){
    cout << A * B << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int he(int x){
	int ans=0;
	while(x){
		ans+=x%10;
		x/=10;
	}
	return ans;
}
int n;
int main(){
	int mn=0x3f3f3f3f;
	cin>>n;
	for(int i=1,j=n-1;i<=j;i++,j--)
		if(he(i)+he(j)<mn) mn=he(i)+he(j);
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int get_cost(vector<int> &a, int val) {
	int c = 0;
	for (int i = 0; i < (int) a.size(); ++i) {
		c += (a[i] - val) * (a[i] - val);
	}

	return c;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> arr(n);
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}

	int min_cost = INT_MAX;
	for (int i = -100; i <= 100; ++i) {
		min_cost = min(min_cost, get_cost(arr, i));
	}

	cout << min_cost << "\n";

	return 0;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int count = 0;
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scanner.nextInt();
        int D = scanner.nextInt();
        int[][] points = new int[N][D];
        for(int i = 0; i < N; i++){
            for(int j = 0; j < D; j++){
                points[i][j] = scanner.nextInt();
            }
        }

        for(int i = 0; i < N; i++){
            int[] point = points[i];
            for(int j = i + 1; j < N; j++){
                int[] otherP = points[j];
                int temp = 0;
                for(int k = 0; k < D; k++){
                    temp = temp + (point[k] - otherP[k]) * (point[k] - otherP[k]);
                }
                if(Math.sqrt(temp) - Math.floor(Math.sqrt(temp)) == 0){
                    count++;
                }
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 23764
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
int n=read();
struct node{
int x,y,id;
bool operator <(const node &b) const{
  return x<b.x;
  }
}a[yuzu|10];

bool cmp(node a,node b){return a.y<b.y;}

struct edge{
int u,v;ll cost;
bool operator <(const edge &b) const{
  return cost<b.cost;
  }
}bian[yuzu<<1|10];

struct dsu{
int fa[yuzu|10];
void init(int n){for (int i=1;i<=n;++i) fa[i]=i;}
int find(int x){return fa[x]^x?fa[x]=find(fa[x]):x;}
void mg(int u,int v){fa[find(u)]=find(v);}
}my_;

bool same(int u,int v){
return my_.find(u)==my_.find(v);
}
ll ans;

int main(){
int i,cnt=0;
for (i=1;i<=n;++i) a[i].x=read(),a[i].y=read(),a[i].id=i;
sort(a+1,a+n+1);
for (i=1;i<n;++i) bian[++cnt]={a[i].id,a[i+1].id,a[i+1].x-a[i].x};
sort(a+1,a+n+1,cmp);
for (i=1;i<n;++i) bian[++cnt]={a[i].id,a[i+1].id,a[i+1].y-a[i].y};
sort(bian+1,bian+cnt+1);
my_.init(n);
for (i=1;i<=cnt;++i){
  if (same(bian[i].u,bian[i].v)) continue;
  my_.mg(bian[i].u,bian[i].v);
  ans+=bian[i].cost; 
  }
write(ans);
}

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

int main() 
{
    // freopen("./input.txt", 'r', stdin);
    // freopen("./output.txt", 'w', stdout);

	int A, B;
	scanf("%d %d", &A, &B);
	int c = A + B;
	int d = A - B;
	int e = A * B;
	if (c >= d && c >= e) {
		printf("%d\n", c);
	} else if (d >= c && d >= e) {
		printf("%d\n", d);
	} else {
		printf("%d\n", e);
	}

	return 0;
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, K;

  void init() {
    scanf("%lld %lld", &N, &K);
  }

  void solve() {
    ll a = (N+K) % K;
    ll b = K-a;
    printf("%lld\n", min(a, min(b, N)));
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)    for (ll i = (ll)b; i < (ll)e; i++)
#define forr(i, b, e)    for (ll i = (ll)b; i < (ll)e; i++)
ll faster_in(){ll r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e9 + 7);
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 3200000
ll v[tam],vc[tam];
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll valor;
    multiset<ll> sa,sb;
    forr(i,0,a)
    {
        cin>>valor;
        sa.insert(valor);
        if (sa.size()>x)
            sa.erase(sa.begin());
    }    
    forr(i,0,b)
    {
        cin>>valor;
        sb.insert(valor);
        if (sb.size()>y)
            sb.erase(sb.begin());
    }
    auto ite=sa.begin();
    forr(i,0,x)
    {
        v[i]=*ite;
        ite++;
    }
    auto ite2=sb.begin();
    forr(i,0,y)
    {
        v[i+x]=*ite2;
        ite2++;
    }
    sort(v,v+x+y);

    ll suma=0;
    forr(i,0,x+y)
    suma+=v[i];
    forr(i,0,c)
    {
        cin>>vc[i];
    }
    sort(vc,vc+c);
    reverse(vc,vc+c);
    forr(i,0,min(c,x+y))
    {
        ll delta=vc[i]-v[i];
        if (delta<=0)
            break;
        suma+=delta;
    }
    cout<<suma<<endl;
}
// PLUS ULTRA!


Measured memory_bytes: 11520
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    vector<long long int> sum(N);
    sum.at(0) = A.at(0);
    for(int i=1; i<N; i++) {
        sum.at(i) = sum.at(i-1) + A.at(i);
    }
    long long int ans = INT32_MAX;
    for(int i=0; i<N; i++) {
        long long int diff = sum.at(N-1) - 2*sum.at(i);
        ans = min(ans, abs(diff));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

int main(void){
    int num, sleep_time=0;
    scanf("%d", &num);

    char title[num][101], sleep_title[101];
    int second[num];

    for(int i=0; i<num; i++){
        scanf("%s %d", title[i], &second[i]);
    }

    scanf("%s", sleep_title);

    for(int i=0; i<num; i++){
        if(strcmp(title[i], sleep_title) == 0){
            for(int j=i+1; j<num; j++){
                sleep_time += second[j];
            }
            break;
        }
    }

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

    return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[210];
    rep(i,0,N) cin >> A[i];
    ll cnt[210] = {};
    rep(i,0,N){
        while(A[i] % 2 == 0){
            cnt[i]++;
            A[i] /= 2;
        }
    }
    ll ans = INF;
    rep(i,0,N) ans = min(ans, cnt[i]);
    print(ans);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
char S[3];

int main()
{
    cin >> S;

    if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R')
    {
        cout << 3 << endl;
    }
    else if ((S[0] == 'R' && S[1] == 'R' && S[2] == 'S') || (S[0] == 'S' && S[1] == 'R' && S[2] == 'R'))
    {
        cout << 2 << endl;
    }
    else if (S[0] == 'S' && S[1] == 'S' && S[2] == 'S')
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3564
S = input()
T = input()
ans = 1
if len(S) + 1 != len(T):
    ans = 0

if ans == 1:
    for i in range(len(S)):
        if S[i] != T[i]:
            ans = 0

if ans == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61616
#include <stdio.h>

int main(void)
{
    int n = 50;
    int m[51];
    int f[51];
    int r[51];
    int i,l,k;
    int c[51];

    for( i = 1; i <= 50; i++){
        scanf("%d %d %d", &m[i], &f[i], &r[i]);
        if( m[i] == -1 && f[i] == -1 && r[i] == -1 )    break; 
    }
    for( l = 1; l <= i - 1; l++){
        if( m[l] == -1 || f[l] == -1 ){
            c[l] = 'F'; continue;
        } else if( m[l] + f[l] >= 80 ){
            c[l] = 'A'; continue;
        } else if( m[l] + f[l] >= 65 ){
            c[l] = 'B'; continue;
        } else if( m[l] + f[l] >= 50 ){
            c[l] = 'C'; continue;
        } else if( m[l] + f[l] >= 30 ){
            if( r[l] >= 50 ){
                c[l] = 'C'; continue;
            } else {
                c[l] = 'D'; continue;
            }
        } else {
            c[l] = 'F'; continue;
        }
    }
    for( k = 1; k <= i - 1; k++){
        printf("%c\n", c[k]);
    }
    return 0;
}


Measured memory_bytes: 2096
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        A: i64,
        B: i64,
        C: i64,
    }

    let ans = std::cmp::max(C - (A - B), 0);
    println!("{}", ans);
}


Measured memory_bytes: 2148
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split())) + [0]

bonus = 0
x = 0
for i in range(n+1):
    enemy = max(0, a[i] - bonus) 
    tmp = enemy - b[i]
    if tmp <= 0:
        x += a[i]
        bonus = -tmp
    else:
        x += (b[i] + bonus)
        bonus = 0

print(x)

Measured memory_bytes: 18624
n = input()

if len(n) == 1:
    print(n)
elif len(n) == 2:
    print(9)
elif len(n) == 3:
    print(int(n)-90)
elif len(n) == 4:
    print(909)
elif len(n) == 5:
    print(int(n)+910-10000)
elif len(n) == 6:
    print(90909)


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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a).size()
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define endl "\n"

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
//K-th smallest
//cout << k << "rd smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;


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

ll mod=1000000007;

ll power(ll x, ll y) 
{
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return (temp*temp)%mod;
	else
		return (((x*temp)%mod)*temp)%mod; 
}

ll dp[100005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,W;
	cin>>n>>W;
	vector<ll> w,v;
	ll i;
	for(i=0;i<n;i++)
	{
		ll w1,v1;
		cin>>w1>>v1;
		w.pb(w1);
		v.pb(v1);
	}
	ll j;
	ll ans=0;
	for(i=0;i<n;i++)
	{
		ll we=w[i];
		ll val=v[i];
		for(j=W;j>=we;j--)
		{
			dp[j]=max(dp[j], dp[j-we]+val);
			ans=max(ans,dp[j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll arr[100100],n,ans,temp,a,b,num,count1,count2,st,temp1,temp2,m,w,h,brr[1010][1010];
int main()
{
    cin>>h>>w>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    st=1;
    for(int i=1;i<=h;i++)
    {
        if(i%2==0)
        {
            for(int j=w;j>=1;j--)
            {
                brr[i][j]=st;
                arr[st]--;
                if(arr[st]==0)
                    st++;
            }
        }
        else
        {
            for(int j=1;j<=w;j++)
            {
                brr[i][j]=st;
                arr[st]--;
                if(arr[st]==0)
                    st++;
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)
            cout<<brr[i][j]<<" ";
        cout<<endl;
    }
return 0;
}


Measured memory_bytes: 2816
#                               #
    # author : samars_diary #
    # 16-09-2020 │ 18:28:11 #
#                               #

import sys, os.path, math

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

# sys.setrecursionlimit(10 ** 5)

mod =  1000000007
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

a=ii();print((pow(10,a,mod)+pow(8,a,mod)-2*pow(9,a,mod))%mod)


Measured memory_bytes: 9080
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function main() {
	var s = readLine().split(" ");
	var a = parseInt(s[0]);
	var op = s[1];
	var b = parseInt(s[2]);
	var c;
	
	if (op == "+"){ c = a+b;}
	else {c = a-b;}
	
	console.log(c);
}


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

int a[100000+1], b[100000+1], s[100000+1];

int main(){
	int i, j;
	
	for (i=2; i<=100000; i++)  a[i]=1;
	
	for (i=2; i<=int(sqrt(100000)); i++){
	  if (a[i]==1)
	    for (j=i+i; j<=100000; j+=i)  a[j] = 0;
    }
    
    b[1]=0; b[2]=0;
    for (i=3; i<=100000; i++)
       if (a[i]==1 && a[(i+1)/2]==1)  b[i]=1;
    
    s[1]=0; s[2]=0;
    for (i=3; i<=100000; i++)
       s[i]= s[i-1] + b[i];
    
    int q, L, r;
    cin >> q;
    
    for (i=1; i<=q; i++){
    	cin >> L >> r;
    	cout << s[r] - s[L-1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int ans = 0;

        for (int i = 1; i < n; i++) {
            int tmp = 0;
            for (int j = i; j < n; j++) {
                tmp += j;

                if (tmp == n) {
                    ans++;
                    break;
                }
                else if (tmp > n)
                    break;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  char a[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  bool r[h] = {}, c[w] = {};
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        r[i] = true;
      }
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      if (a[j][i] == '#') {
        c[i] = true;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (r[i] && c[j]) {
        cout << a[i][j];
      }
    }
    if (r[i]) {
      cout << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

string sa[330];
int s[330][330];
int num[330];

int main(){
	int n,m,p;
	int i,j,k;
	LL a,b,c;
	cin>>n>>m>>p;
	for(i=0;i<n;i++){
		cin>>sa[i];
		for(j=0;j<m;j++){
			if(sa[i][j]=='#')num[i]++;
		}
	}
	a=1;
	for(i=0;i<n;i++){
		if(num[i]==0)continue;
		k=i;
		b=0;
		for(j=0;j<m;j++){
			if(sa[i][j]=='#'){
				b++;
				if(b>1)a++;
			}
			s[i][j]=a;
		}
		a++;
	}
	for(i=k;i>=0;i--){
		if(num[i])continue;
		num[i]=1;
		for(j=0;j<m;j++){
			s[i][j]=s[i+1][j];
		}
	}
	for(i=0;i<n;i++){
		if(num[i])continue;
		for(j=0;j<m;j++){
			s[i][j]=s[i-1][j];
		}
	}
	for(i=0;i<n;i++){
		array_show(s[i],m);
	}
}

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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        int n = in.nextInt();
        String s = in.nextLine();
        int ans = 0, cnt =0;
        for(int i=0;i<n;i++){
            if(s.charAt(i) == 'I'){
                cnt++;
            }else{
                cnt--;
            }
            ans = Math.max(ans,cnt);
        }
        out.print(ans);

    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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

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

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 21204
import sys
import fractions
N,M=map(int, input().split())
A = [int(a) for a in input().split()]
A2 = [a>>1 for a in A]

lcm = A2[0]
for i in range(1, N):
    lcm = lcm * A2[i] // fractions.gcd(lcm, A2[i])
    if lcm>M:
        print(0)
        sys.exit()
    
B = sum([1 for a in A if lcm%a==0])
if B>0:
    print(0)
else:
    print((M//lcm+1)//2)

Measured memory_bytes: 89580
#include <iostream>
#include <string>
 
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
 
int mainC()
{
	string str;
	cin >> str;
	int n = stoi(str);
	map<string, long long> strMap;
  	map<string, int> strMap2;
	for (int i = 0; i < n; ++i)
	{
		cin >> str;
		sort(str.begin(), str.end());
		strMap[str]++;
      	strMap2[str]++;
	}
 
	long long m = 0;
  	long long m2 = 0;
	for (const auto& x : strMap)
	{
		auto k = x.second;
      	auto k2 = strMap2.find(x.first)->second;
		if(k > 1)
			m += (k - 1) * k;
      	if(k2 > 1)
          	m2 += static_cast<long long>((k2 - 1)) * k2;
      if(m!= m2)
        return 0;
	}
	m /= 2;
	cout << m << endl;
	return 0;
 
}
 
int main()
{
	return mainC();
}


Measured memory_bytes: 22144
a, b, c, d = map(int, input().split())
a = a - 1


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)


ac = a // c
ad = a // d
acd = a // lcm(c, d)

bc = b // c
bd = b // d
bcd = b // lcm(c, d)

bx = b - (bc + bd) + bcd
ax = a - (ac + ad) + acd
print(bx - ax)


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

int main() {
    int n;
    int count = 0;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    for (int i = 1; i < n - 1; i++) {
        vector<int> sor(3);
        sor.at(0) = p.at(i - 1);
        sor.at(1) = p.at(i);
        sor.at(2) = p.at(i + 1);
        sort(sor.begin(), sor.end());
        if (sor.at(1) == p.at(i)) count++;
    }
    cout << count << endl;
}


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

#define ll long long
#define mod 1000000007
#define MAX 500005

int main()
{
	ll n, k, q, p;
	cin >> n >> k >> q;

	ll dif=0;
	ll ans[n+1]={0};
	for(int i=0;i<q;i++)
	{
		cin >> p;
		ans[p]++;
	}

	for(int i=1;i<=n;i++)
	{
		ans[i]= k-q+ans[i];
	}

	for(int i=1;i<=n;i++) if(ans[i]>0) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {

	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l[i];

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (i < j && j < k) {
					if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
					if ((long long)l[i] + l[j] + l[k] <= max({ l[i],l[j],l[k] }) * 2) continue;
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3548
import numpy as np
import types
N, D = map(int, input().split())
Xs = []
while True:
  Xs.append(list(map(int, input().split())))
  if len(Xs) == N:
    break
result = []
Xi = 1
tmp = []
for x in Xs:
  tmp.append(x)
  for n in range(N):
    if Xs[n] in tmp:
      l = np.linalg.norm(np.array(x)-np.array(Xs[n]))
      if l.is_integer() and l>0:
        result.append(l)
print(int(len(result)))


Measured memory_bytes: 12508
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll n;cin>>n;
  ll a[n],b[n];
  vector<P> v;
  REP(i,n){
    cin>>a[i]>>b[i];
    P p;
    p.first = b[i];
    p.second = a[i];
    v.pb(p);
  }

  VSORT(v);
  ll num = v[v.size()-1].second;

  for(int i=v.size()-2;i>=0;i--){
    num -= v[i+1].first - v[i].first;
    num = max((ll)0,num);
    num += v[i].second;
    
  }
  num -= v[0].first;
  if(num>0){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }

 

  return 0;
}

Measured memory_bytes: 5492
N=int(input())
c=input()
a=0
b=0
for i in range(N):
    if c[i]=='R':
        a+=1

ans=max(a,b)
for i in range(N):
    if c[i]=='R':
        a-=1
    else:
        b+=1
    now=max(a,b)
    ans=min(ans,now)
print(ans)

Measured memory_bytes: 9472
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, K = getNM()
A = getList()

for i in range(0, N - K):
    if A[i] < A[i + K]:
        print('Yes')
    else:
        print('No')

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

/*int main(){
  string s;
  cin >> s;
  deque<char> d;
  d.push_back('S');
  int q;
  cin >> q;
  bool flag = true;
  rep(i,q){
    int ti;
    cin >> ti;
    cout << "ti " << ti << endl;
    if (ti == 1){
      flag = flag? false : true;
    }
    else {
      int fi;
      char ci;
      cin >> fi >> ci;
      cout << "fi " << fi << endl;
      cout << "ci " << ci << endl;
      cout << "flag " << flag << endl;
      if (flag){
        if (fi == 1) d.push_front(ci);
        else d.push_back(ci);
      }
      else {
        if (fi == 1 ) d.push_back(ci);
        else d.push_front(ci);

      }
    }
    for(auto c : d) cout << c;
    cout << endl;
    cout << endl;
  }
  while (!d.empty()){
    if (flag){
      char c = d.front();
      if (c == 'S'){
        cout << s;
        d.pop_front();
        continue;
      }
      cout << c;
      d.pop_front();
    }
    else {
      reverse(s.begin(), s.end());
      char c = d.back();
      if (c == 'S'){
        cout << s;
        d.pop_back();
        continue;
      }
      cout << c;
      d.pop_back();
    }
  }
  cout << endl;
  return 0;
}*/

int main(){
  string s;
  cin >> s;
  int q;
  cin >> q;
  string t;
  rep(i,q){
    int ti;
    cin >> ti;
    if (ti == 1){
      swap(s, t);
    }
    else {
      int fi;
      char ci;
      cin >> fi >> ci;
      if (fi == 1) t += ci;
      else s += ci;
    }
  }
  reverse(t.begin(), t.end());
  t += s;
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;

int N,A,B,X,Y[100];

signed main(){
    cin>>N>>A>>B>>X;
    rep(i,N)cin>>Y[i];
    sort(Y,Y+N);reverse(Y,Y+N);

    int s=X,t=A,cur=0;
    while(cur<N){
        if(s*(t+B)>(s+Y[cur])*t)break;
        s+=Y[cur++];
        t+=B;
    }
    cout<<s/t<<endl;
    return 0;
}

//s/t s+Y[cur]/t+B

Measured memory_bytes: 1172
#include <stdio.h>
#include <math.h>
int main(void){
    int a,b,C;
    double S,L,h,x,y;
    double PI = acos(-1);
    
    scanf("%d %d %d",&a,&b,&C);
    
    S = (0.5*a*b*sin(C*PI/180));
    x = ((a*a)+(b*b)-(2*a*b*cos(C*PI/180)));
    y = sqrt(x);
    L = (a+b+y);
    h = (2*S/a);
    
    printf("%f %f %f\n",S,L,h);
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int inf = 1e9;
long long mod = 1000000007 ;
long long n, k, u, ans;

int main(){
  cin>>n>>k;
  ans = 0;
  for(long long i = k; i <= n + 1; ++i){
    ans += (n + 1 - i) * i % mod + 1;
    ans %= mod;
  }
  cout<<(ans)<<endl;
  return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

vector<int> G[5002],rG[5002];
int dp[5002];
bool used[5002];
int t = 0;


void dfs(int v){
	int p = 0;
	rep(i,rG[v].size()){
		if(!used[rG[v][i]]){
			dfs(rG[v][i]);
		}
		p = max ( p , dp[rG[v][i]] );
	}
	if(!used[v]){
		used[v] = true;
		printf("%d\n",v);
	}
	dp[v] = p + 1;
	t = max ( t , dp[v] );
	rep(i,G[v].size()){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	
	rep(i,m){
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].pb(y);
		rG[y].pb(x);
	}
	
	rep(i,5002){
		used[i] = false;
		dp[i] = 0;
	}
	
	rep1(i,n){
		if(!used[i]){
			dfs(i);
		}
	}
	
	if(t == n)puts("0");
	else puts("1");
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
template <ll mod = MOD>
class ModCombination
{
public:
    ModCombination(const int n) : fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1)
    {
        for (ll i = 2; i <= n; i++) { fact[i] = (fact[i - 1] * i) % mod, inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod, inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod; }
    }
    ll combination(const int n, const int k) const { return n == -1 and k == -1 ? 1LL : 0 <= k and k <= n ? (((fact[n] * inv_fact[k]) % mod) * inv_fact[n - k]) % mod : 0LL; }

private:
    vector<ll> fact, inv, inv_fact;
};
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }
template <typename T, typename A>
inline ostream& operator<<(ostream& os, const deque<T, A>& v)
{
    os << "[";
    for (const auto& p : v) { os << p << ","; }
    return (os << "]" << endl);
}

int main()
{
    ModCombination<> mod(200);
    int N;
    cin >> N;
    vector<vector<int>> g(N);
    vector<int> prev(N, -1);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        prev[v] = u;
    }
    auto merge = [&](const deque<ll>& v1, const deque<ll>& v2) {
        const int s1 = v1.size() - 1, s2 = v2.size() - 1;
        deque<ll> ans(s1 + s2 + 1);
        for (int i = 0; i <= s1; i++) {
            if (v1[i] == 0) { continue; }
            for (int j = 0; j <= s2; j++) {
                if (v2[j] == 0) { continue; }
                for (int c = 0; c <= min(i, j); c++) { (ans[i + j - c] += (mod.combination(i + j - 2 * c, i - c) * mod.combination(i + j - c, c) % MOD) * (v1[i] * v2[j] % MOD) % MOD) %= MOD; }
            }
        }
        return ans;
    };
    auto dp = fix([&](auto&& self, const int s) -> deque<ll> {
        deque<ll> ans{1};
        for (const int to : g[s]) { ans = merge(ans, self(self, to)); }
        ans.push_front(0);
        return ans;
    });
    int r = 0;
    for (; prev[r] >= 0 and r < N; r++) {}
    const auto v = dp(r);
    ll ans = 0;
    for (const ll e : v) { (ans += e) %= MOD; }
    cout << ans << endl;
    return 0;
}



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

int main(){
  int N,L;
  cin >> N >> L;
  
  int taste0 = 0;
  for(int i = 0; i < N ; i++){
    taste0 += L + ( i+ 1) -1; 
  }
  
  int min = 1000;
  int id = 0;
  for(int i = 0; i < N ; i++){
    if(abs(L + (i+ 1) -1) < min){
      min = abs(L + (i+ 1) -1);
      id = (i+ 1);
    }
  }
  
  cout  << taste0 -(L + id -1)<< endl;
  
  return 0; 
}

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

int main(){
  
  int num[102]={},N=0,mini,cnt=0;
  
  cin >> N;
  
  for(int i = 0; i < N; i++){
    cin >> num[i];
  }
  
  for(int i = 0; i < N; i++){
    mini = i;
    for(int j = i; j < N; j++){
      if(num[j] < num[mini]) 	mini = j;
    }
    swap(num[i],num[mini]);
    if(num[i] < num[mini])    cnt++;
  }
  
  for(int i = 0; i < N; i++){
    cout << num[i];
    if(i != N-1) cout << " ";
  }
  cout << endl << cnt <<endl;

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int c=0,ans=0;
  for(int i=0;i<3;i++)
  {
    char ch;
    cin>>ch;
    if(ch=='R')
      c++;
    else
    {
      ans=max(ans,c);
      c=0;
    }
  }
  ans=max(ans,c);
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int n, dat[262200];

void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    for (int i = 0; i < 2 * n - 1; i++) dat[i] = pow(2, 31) - 1;
}

// k番目の値をaに変更
void update(int k, int a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

// [a, b)の最小値を求める．
int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return pow(2, 31) - 1;
    
    if (a <= l && r <= b) return dat[k];
    else {
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}

int main(void){
    int q;
    cin >> n >> q;
    
    init(n);
    
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) cout << query(x, y + 1, 0, 0, n) << endl;
        else update(x, y);
    }
}



Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string str;
	int n;
	cin >> n >> str;
	for (int i =0;i<str.size();i++) {
		cout << (char)(((str[i] - 'A') + n) % 26 + 'A');
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 888