akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 1> { using type = vector<T>; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const ll MOD = 1e9 + 7;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

int main() {
  string S;
  while (cin >> S) {
    vec<ll, 2> dpA = make_v(S.size() + 1, 4, 0ll);
    vec<ll, 2> dpB = make_v(S.size() + 1, 4, 0ll);
    vec<ll, 2> dpC = make_v(S.size() + 1, 4, 0ll);
    for (int i = 0; i < S.size(); i++) {
      for (int j = 0; j < 4; j++) {
        dpA[i + 1][j] = dpA[i][j];
        dpB[i + 1][j] = dpB[i][j];
        dpC[i + 1][j] = dpC[i][j];
      }
      int add = S[i] == '?';
      if (S[i] == 'A' || S[i] == '?') {
        (dpA[i + 1][add] += 1) %= MOD;
      }
      if (S[i] == 'B' || S[i] == '?') {
        for (int j = 0; j < 2; j++) {
          (dpB[i + 1][j + add] += dpA[i][j]) %= MOD;
        }
      }
      if (S[i] == 'C' || S[i] == '?') {
        for (int j = 0; j < 3; j++) {
          (dpC[i + 1][j + add] += dpB[i][j]) %= MOD;
        }
      }
    }
    int Q = count(S.begin(), S.end(), '?');
    ll res = 0;
    for (int j = 0; j < 4; j++) {
      res = (res + dpC[S.size()][j] * power(3, Q - j) % MOD) % MOD;
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	const int MOD = 1e9 + 7;
	long long res = n;
	while (--n) {
		res *= n;
		res %= MOD;
	}
	cout << res << '\n';

	return 0;
}



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

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) (v.size())
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

LL MOD = 1000000007; 

using namespace std;


LL solve(vector<LL> &v, LL X) {
    LL ans = 0;
    for(int i = 1; i < v.size(); ++i) {
        LL t = v[i - 1] + v[i];
        if (t > X) {
            LL diff = min(t - X, v[i]);
            ans += diff;
            v[i] -= diff;
        }
    }
    
    return ans;
}

int main(int argc, char *argv[]) {
    LL N, X, a;
    cin >> N >> X;
    vector<LL> v;
    LL ans = 0;
    FOR(i, 0, N) {
        cin >> a;
        if (a > X) {
            ans += a - X;
            a = X;
        }
        v.push_back(a);
    }
    
    ans += solve(v, X);
    
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
#include<string.h>
char s[105][105];
int a[105];
int b[105];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",&s[i]);
        scanf("%d",&a[i]);
        b[i]=i+1;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(strcmp(s[i],s[j])>0)
            {
                char ss[i][j];
                strcpy(ss[i],s[i]);strcpy(s[i],s[j]);strcpy(s[j],ss[i]);
                int t=a[i];a[i]=a[j];a[j]=t;
                int k=b[i];b[i]=b[j];b[j]=k;
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(strcmp(s[i],s[j])==0&&a[i]<a[j])
            {
                char ss[i][j];
                strcpy(ss[i],s[i]);strcpy(s[i],s[j]);strcpy(s[j],ss[i]);
                int t=a[i];a[i]=a[j];a[j]=t;
                int k=b[i];b[i]=b[j];b[j]=k;
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        printf("%d\n",b[i]);
    }
    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, k;
  std::cin >> n >> k;
  int ans = 1;
  REP(i, n) { ans = min(2 * ans, ans + k); }
  print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    std::string s;
    int a;
    std::cin >> a >> s;
    if(a>=3200) std::cout << s << std::endl;
    else std::cout << "red" << std::endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * If you're not willing to make sacrifices yourself, you'll never be
 * able to change anything. In order to overcome monsters, you must
 * be willing to abandon your own humanity.
 * ~ Arlert
 */

#include <bits/stdc++.h>

using namespace std;

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

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

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

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'
const int N = 300;
int x[N][N];
int rm[N][N];
int main() {
  fast_io;
  int n;
  cin >> n;
  LL sum = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> x[i][j], sum += x[i][j];
  sum /= 2;
  int poss = 1;
  for (int k = 0; k < n; k++)
    for (int j = 0; j < n; j++)
      for (int i = 0; i < n; i++)
        if (x[i][k] + x[k][j] < x[i][j]) poss = 0;
  if (!poss) return 0 * puts("-1");
  for (int tr = 0; tr < 400; tr++) {
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        for (int k = 0; k < n && !rm[i][j]; k++)
          if (k != i && k != j)
            if (x[i][k] + x[k][j] == x[i][j])
              rm[j][i] = rm[i][j] = 1, sum -= x[i][j];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000009
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    int maxi = 0;
    for(int i=0;i<n-m+1;i++){
        string ans = s.substr(i,m);
        int cnt=0;
        for(int j=0;j<ans.length();j++){
            if(ans[j]==t[j])
                cnt++;
        }
        maxi=max(maxi,cnt);
    }
    cout<<m-maxi<<endl;
    return 0;
}


Measured memory_bytes: 3660
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n 

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


def resolve():
    N, M = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for i in range(M)]
    cnt = 0
    for i in range(len(AB)):
        uf = UnionFind(N)
        for edge in AB[:i]+AB[i+1:]:
            uf.union(edge[0]-1, edge[1]-1)
        if uf.find(AB[i][0]-1) != uf.find(AB[i][1]-1):
            cnt += 1
    print(cnt)


if '__main__' == __name__:
    resolve()

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

int min(int a, int b){
	return a < b ? a : b;
}

int main(void){
	int n;
	int *a, in;
	long count = 0;
	scanf("%d", &n);
	a = malloc(sizeof(int) * (n + 1));
	for(int i = 0; i < n + 1; i++)
		scanf("%d", a + i);
	for(int i = 0; i < n; i++){
		scanf("%d", &in);
		int left = min(a[i], in);
		int right = min(a[i + 1], in - left);
		count += left + right;
		a[i + 1] -= right;
	}
	printf("%ld\n", count);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int, int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
    #ifndef EB_UG
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #endif
}

int main() {
    kekek();
    int a;
    cin >> a;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == a) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
n = int(input())

A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

C = zip(B, A)
C = sorted(C)
B, A = zip(*C)

ans = 1
t = 0
for i, j in zip(A, B):
    t += i
    if t <= j:
        continue
    else:
        print("No")
        ans = 0
        break
if ans:
    print("Yes")

Measured memory_bytes: 49196
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N=1003;
const ll lmod = 1e9+7;

map<char,int> mp;

int main(){
  int h,w;
  cin >> h >> w ;
  rep(i,h){
    string s;
    cin >> s ;
    rep(j,w){
      char c = s[j];
      if(!EXIST(mp,c)){
        mp[c]=1;
      }else{
        mp[c]++;
      }
    }
  }
  int cnt1,cnt2,cnt4;
  cnt1 = cnt2 = cnt4 = 0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    int num = itr->second;
    // cout << itr->first << "," << num << endl;
    cnt4 += num/4;
    if(num%2==1) cnt1++; 
  }
  bool ans;
  if((h*w)%2==1){
    ans = ((cnt4>=(h/2)*(w/2))&&(cnt1==1));
  }else{
    ans = ((cnt4>=(h/2)*(w/2))&&(cnt1==0));
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
// #include <string.h>
// #include <math.h>

int main() {
    int n,num,i,j,S[4][13]={0};
    char c,ss[]={[0]='S',[1]='H',[2]='C',[3]='D'};
    // S[0][0]=0;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%c",&c);
        scanf("%c %d",&c,&num);
        for(j=0;j<4;j++){
            if(c==ss[j]){
                S[j][num-1]=1;
                break;
            }
        }
        
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(S[i][j]!=1){
                printf("%c %d\n",ss[i],j+1);
            }
        }
        
    }
   
    return 0;
}


Measured memory_bytes: 2140
#include <cstdio>
#include <cstdlib>
#include <algorithm>


/** 骞舵煡闆? */
typedef struct ufs_t {
    int *p;     /** 鏍戠殑鍙屼翰琛ㄧず娉?*/
    int size;   /** 澶у皬. */
} ufs_t;

/**
 * @brief 鍒涘缓骞舵煡闆?
 * @param[in] n 鏁扮粍鐨勫閲?
 * @return 骞舵煡闆?
 */
ufs_t* ufs_create(int n) {
    ufs_t *ufs = (ufs_t*)malloc(sizeof(ufs_t));
    int i;
    ufs->p = (int*)malloc(n * sizeof(int));
    for(i = 0; i < n; i++)
        ufs->p[i] = -1;
    return ufs;
}

/**
 * @brief 閿€姣佸苟鏌ラ泦.
 * @param[in] ufs 骞舵煡闆?
 * @return 鏃?
 */
void ufs_destroy(ufs_t *ufs) {
    free(ufs->p);
    free(ufs);
}

/**
 * @brief Find鎿嶄綔锛屽甫璺緞鍘嬬缉锛岄€掑綊鐗?
 * @param[in] s 骞舵煡闆?
 * @param[in] x 瑕佹煡鎵剧殑鍏冪礌
 * @return 鍖呭惈鍏冪礌x鐨勬爲鐨勬牴
 */
int ufs_find(ufs_t *ufs, int x) {
    if (ufs->p[x] < 0) return x; // 缁堟鏉′欢

    return ufs->p[x] = ufs_find(ufs, ufs->p[x]); /* 鍥炴函鏃剁殑鍘嬬缉璺緞 */
}

/** Find鎿嶄綔锛屾湸绱犵増, deprecated. */
static int ufs_find_naive(ufs_t *ufs, int x) {
    while (ufs->p[x] >= 0) {
        x = ufs->p[x];
    }
    return x;
}

/** Find鎿嶄綔锛屽甫璺緞鍘嬬缉锛岃凯浠ｇ増. */
static int ufs_find_iterative(ufs_t *ufs, int x) {
    int oldx = x; /* 璁板綍鍘熷x */
    while (ufs->p[x] >= 0) {
        x = ufs->p[x];
    }
    while (oldx != x) {
        int temp = ufs->p[oldx];
        ufs->p[oldx] = x;
        oldx = temp;
    }
    return x;
}

/**
 * @brief Union鎿嶄綔锛屽皢y骞跺叆鍒皒鎵€鍦ㄧ殑闆嗗悎.
 * @param[in] s 骞舵煡闆?
 * @param[in] x 涓€涓厓绱?
 * @param[in] y 鍙︿竴涓厓绱?
 * @return 濡傛灉浜岃€呭凡缁忓湪鍚屼竴闆嗗悎锛屽苟澶辫触锛岃繑鍥?1锛屽惁鍒欒繑鍥?
 */
int ufs_union(ufs_t *ufs, int x, int y) {
    const int rx = ufs_find(ufs, x);
    const int ry = ufs_find(ufs, y);
    if(rx == ry) return -1;

    ufs->p[rx] += ufs->p[ry];
    ufs->p[ry] = rx;
    return 0;
}

/**
 * @brief 鑾峰彇鍏冪礌鎵€鍦ㄧ殑闆嗗悎鐨勫ぇ灏?
 * @param[in] ufs 骞舵煡闆?
 * @param[in] x 鍏冪礌
 * @return 鍏冪礌鎵€鍦ㄧ殑闆嗗悎鐨勫ぇ灏?
 */
int ufs_set_size(ufs_t *ufs, int x) {
    const int rx = ufs_find(ufs, x);
    return -ufs->p[rx];
}

int main(void)
{
    int N,M;
    int x,y;

    scanf("%d%d",&N,&M);

    ufs_t *Union1 = ufs_create(N);

    for (int i=0;i<M;i++)
    {
        scanf("%d%d",&x,&y);
        ufs_union(Union1,x-1,y-1);
    }
    int maxVal = 0;
    for(int i=0;i<N;i++)
    {
        maxVal = std::max(maxVal,
            ufs_set_size(Union1,i) );
    }
    printf("%d\n",maxVal);
    ufs_destroy(Union1);
    return 0;
}


Measured memory_bytes: 2248
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,a[3030],j,k,has;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(i=1;i<=n;i++)
	{
		k=i+1;
		for(j=i+1;j<=n;j++)
		{
			while((k<n)&&((a[i]+a[j])>a[k+1]))k++;
			// cout<<i<<" "<<j<<" "<<k<<"\n";
			has+=(k-j);
		}
	}
	cout<<has<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  long long N, A, B;
  scanf("%lld",&N);
  scanf("%lld",&A);
  scanf("%lld",&B);
  long long sho = N/(A+B);
  long long amari = N%(A+B);
  long long ans = sho*A+std::min(amari, A);
  printf("%lld\n", ans);
  return 0;
}


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

int i[1000], p[1000], q[1000], r[1000];
int main() {
	int n;
	while (cin >> n, n) {
		vector<int>v;
		rep(j, n) {
			cin >> i[j] >> p[j] >> q[j] >> r[j];
		}
		int P, Q, R, C; cin >> P >> Q >> R >> C;
		rep(j, n) {
			if (p[j] <= P&&q[j] <= Q&&r[j] <= R && 4 * p[j] + 9 * q[j] + 4 * r[j] <= C)
				v.push_back(i[j]);
		}
		if (v.empty())puts("NA");
		for (int j : v)cout << j << endl;
	}
}

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

ll dp[1001][1001];

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

  dp[0][0]=1;
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=i;j++){
      dp[i][j]+=dp[i-1][j-1]*(k-j+1);
      dp[i][j]+=dp[i-1][j]*j;
      dp[i][j]%=mod;
    }
  }
  cout<<dp[n][k]<<endl;
  return 0;
}



Measured memory_bytes: 9980
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        while(true){
            String n = sc.next();
            if(n.equals("0"))    break;
            long ans=0;
            for(int i=0;i<n.length();i++){
                ans += n.charAt(i) - '0';
            }

            System.out.println(ans);

        }





        sc.close();


    }
}


Measured memory_bytes: 26240
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k,cnt,ans;
int main()
{
    scanf("%d%d",&n,&k);ans=1;
    while(cnt<n&&ans<k) ans+=ans,++cnt;
    ans+=k*(n-cnt);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[] h=new long[s[0]+1];
		for(int i=1;i<=s[0];i++){h[i]=long.MinValue;}
		h[1]=0;
		long[][] arr=new long[s[1]][];
		for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}

		long l=0;
		bool b=false;
		while(l<=s[0]+1){
			l++;
			for(int i=0;i<s[1];i++){
				if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){
					h[arr[i][1]]=h[arr[i][0]]+arr[i][2];
					if(l>s[0]&&arr[i][1]==s[0]){b=true;}
				}
			}
		}
		Console.WriteLine("{0}",b?"inf":h[s[0]].ToString());
	}
}

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

int main() {
  long n;
  cin >> n;
  long cnt = 1;
  long sum = 0;
  while (n > 0) {
    sum += cnt;
    n /= 2;
    cnt *= 2;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<int>p(N+1);
	vector<int>w(N+1);
	for (int i = 1; i <= N; i++) {
		cin >> p[i] >> w[i];
	}
	int ans = MOD;
	for (int i = 0; i < 1 << N; i++) {
		int cnt = 0;
		int box = 0;
		for (int j = 0; j < N; j++) {
			if ((i >> j) & 1) {
				box += p[j + 1] * (j + 1) * 100;
				box += w[j + 1];
				cnt += p[j + 1];
			}
		}
		for (int j = N - 1; j >= 0; j--) {
			if ((i >> j) & 1)continue;
			int ccnt = 0;
			while (box < M&&ccnt + 1 < p[j + 1]) {
				box += (j + 1) * 100;
				cnt++;
				ccnt++;
			}
		}
		if (box >= M) {
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m;
    cin, n, m;
    ll sum = 0;
    REP(i, 0, m) {
        ll a;
        cin, a;
        sum += a;
    }
    cout << (n >= sum ? n - sum : -1) << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
long long n,a[300006],s,sum=0,sum1=0;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;++i)
    {
		sum1+=(a[i]*sum);
		sum1%=1000000007;
		sum+=a[i];
		sum%=1000000007;
	}
	/*sort(a+1,a+n);
	for(int i=1;i<=n;++i)
	{
		s=sqrt(a[i])+1;
		for(int j=1;j<=s;++j)
		{
			if(a[j]>s)
			break;
			if(a[i]%a[j]==0&&a[i]!=a[j])
			sum+=a[i];
		}
	}*/
	printf("%lld",sum1%1000000007);
	return 0;
}

Measured memory_bytes: 5340
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 16;

int n;
int a[MAXN][MAXN];
long long cost[(1 << MAXN) + 1023];
long long dp[(1 << MAXN) + 1023];

void calc(int pos, int mask, int submask) {
  if (pos == n) {
    dp[mask] = max(dp[mask], dp[submask] + cost[mask - submask]);
    return;
  }
  calc(pos + 1, mask, submask);
  calc(pos + 1, mask | (1 << pos), submask);
  calc(pos + 1, mask | (1 << pos), submask | (1 << pos));
}

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        cost[i] = cost[i ^ (1 << j)];
        for (int k = j + 1; k < n; k++) {
          if (i & (1 << k)) {
            cost[i] += a[j][k];
          }
        }
        break;
      }
    }
  }

  calc(0, 0, 0);

  cout << dp[(1 << n) - 1] << endl;

  return 0;
}


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

int main(void)
{
    string s;

    cin >> s;

    if(s[0] == s[1] && s[1] == s[2])
        cout << "Yes" << endl;
    else if(s[1] == s[2] && s[2] == s[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, j, n, prime[200000] = {},c;
  long long int sum;
  prime[0] = prime[1] = 1;
  for(i = 2;i < 200000;i++){
    if(prime[i] != 1){
      for(j = 2 * i;j < 200000;j += i){
	prime[j] = 1;
      }
    }
  }

  while(scanf("%d", &n) && n){
    c = 0; sum = 0;
    for(i = 0;i < 200000;i++){
      if(prime[i] != 1){
	c++;
	sum += i;
	if(c == n) break;
      }
    }
    printf("%lld\n", sum);
  }
  return 0;
}

Measured memory_bytes: 1388
def main():
  A,B,M=map(int, input().split())
  a=list(map(int, input().split()))
  b=list(map(int, input().split()))
  ans=min(a)+min(b)
  for i in range(M):
    x,y,c=map(int, input().split())
    ans=min(a[x-1]+b[y-1]-c,ans)
  print(ans)
  return

main()

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

long long n, ans = 1, M = 1e9 + 7;
int main()
{
	cin >> n;
	while (n--) {
		ans = ans * (n + 1) % M;
	}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
solve :: String -> String -> Int -> Int
solve (s:sx) (t:tx) ans
 | sx == []         = newAns
 | otherwise        = solve sx tx newAns
  where newAns = ans + if s == t then 0 else 1

main :: IO ()
main = do 
 s <- getLine :: IO String
 t <- getLine :: IO String
 print $ solve s t 0

Measured memory_bytes: 19948
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(LL, a);
	IN(string, s);
	s.erase(1, 1);
	LL b = stoll(s);
	OUT(a * b / 100);
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll A,B,K;
  cin>>A>>B>>K;
  if(K>=A){
    K=K-A;
    A=0;
    if(K>=B){
      B=0;
    }else{
      B=B-K;
    }
  }else{
    A=A-K;
  }
  cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
// Longest Path in DAG //


#include <bits/stdc++.h>
using namespace std;
using vi = vector <int> ;
using ll = long long;

#define IOS ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define trace(x)  for (auto itr : x)
#define rep(i, n) for (auto i = 0; i < n; ++i)
#define repi(i, x, n) for (auto i = x; i <= n; ++i)



const int N=1e5+5;


//dfs 
void dfs(int node, vi adj[], int dp[], bool vis[]) {
	vis[node] = true;
	for(int i=0; i<adj[node].size(); ++i) {
		if(!vis[adj[node][i]])
			dfs(adj[node][i], adj, dp,vis);
		//dp[i] - length of longest path starting from node i
		dp[node] = max(dp[node], 1+ dp[adj[node][i]]);
	}
}


int solve(vi adj[], int n) {
	int dp[n+1];
	bool vis[n+1];
	fill(dp,0);
	fill(vis,false);

	repi(i,1,n)
		if(!vis[i])
			dfs(i,adj,dp,vis); // call dfs for every unvisited vertix

	int ans = 0;
	for(int i=0; i<=n; i++)
		ans = max(ans,dp[i]);
	return ans;

}

int32_t main()
{
	IOS;
	int n,m,u,v;
	cin>>n>>m;
	vi adj[n+1];
	while(m--){
		cin>>u>>v;
		adj[u].pb(v);
	}

	cout<<solve(adj,n)<<endl;

	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
double dp[310][310][310];
int N, c[4];

double solve(int i, int j, int k)
{
  if (i == 0 && j == 0 && k == 0)
    return 0.0;
  if (dp[i][j][k] > 0)
    return dp[i][j][k];
  double p = N;
  if (i > 0)
    p += solve(i - 1, j, k) * i;
  if (j > 0)
    p += solve(i + 1, j - 1, k) * j;
  if (k > 0)
    p += solve(i, j + 1, k - 1) * k;
  p /= (i + j + k);
  return dp[i][j][k] = p;
}

int main()
{
  int a;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    c[a]++;
  }
  cout << fixed << setprecision(10) << solve(c[1], c[2], c[3]) << endl;
}


Measured memory_bytes: 114268
'use strict'

function main(s) {

  s = s.split('\n')
  const str = s[0];
  const len = str.length;
  const k   = Number(s[1]);

  // 文字列に出現する文字を辞書順に並び替えて取得
  // ex). [ 'a', 'c', 'd', 'e', 'n', 'o', 'r', 't' ]
  const initials = [...new Set(str.split(''))].sort();
  let index = 0;
  const dic = new Set();

  // ex). 'a'でk個辞書が集まらなければ, 次の'c'のループへ...
  while (dic.size < k) {
    for (let i = 0; i < len; i++) {
      let j = 1;
      if (str.slice(i, i + j) !== initials[index]) continue;

      // 'a'に一致する地点から最大5文字分辞書に追加
      while (i + j <= len && j <= 5) {
        dic.add(str.slice(i, i + j));
        j += 1;
      }
    }
    index += 1;
  }

  const ans = [...dic].sort()[k - 1];
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8088
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef set<int>        si;

template<typename T> T sgn (T x)      {return x<0? -1:x!=0; }
template<typename T> T gcd (T a, T b) {return a ? gcd (b % a, a) : b; }
//pi=acos(-1)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define popcount __builtin_popcount
#define eb emplace_back
#define emp emplace
#define ss second
#define ff first
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

ll a, b, c, ans, k;

void solve(){
    scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
    if(k<=a+b)ans = min(a,k);
    else ans = a-min(k-a-b,c);
    printf("%lld\n",ans);
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;//scanf("%d",&t);
    while(t--)solve();
}

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

const int maxn = 2e5 + 7;

int val[maxn], anc[maxn];

struct Point {
	long long ones, zeros;
	int inx;
} ;

bool operator < (const Point &a, const Point &b) {
	return a.ones * b.zeros > b.ones * a.zeros; 
}

Point &operator += (Point &a, const Point &b) {
	a.zeros += b.zeros;
	a.ones += b.ones;
	return a;
}

int p[maxn];
Point D[maxn];
vector<int> e[maxn];
int find(int x) {
	if (p[x] == x) return x;
	return p[x] = find(p[x]);
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		scanf("%d", &anc[i]);
		e[ anc[i] ].push_back(i);
	}
	for (int i = 1; i <= n; i++) p[i] = i;

	priority_queue<Point> pq;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &val[i]);
		if (val[i]) D[i] = Point{1LL, 0LL, i};
		else D[i] = Point{0LL, 1LL, i};
		if (i != 1) pq.push(D[i]);
	}

	long long ans = 0;
	while (!pq.empty()) {
		Point tmp = pq.top(); pq.pop();
		if (p[tmp.inx] != tmp.inx) continue;

		int u = tmp.inx, v = find(anc[u]);

		// cout << u << ' ' << v << endl;

		ans += (long long)D[v].ones * D[u].zeros;

		p[u] = v;
		D[v] += D[u];
		// cout << D[v].inx << endl;
		// system("pause");
		if (v != 1) pq.push(D[v]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 26224
#include <bits/stdc++.h> 
using namespace std;
using ll=long long;
const int N=3005;
int a[N];
ll memo[N][N][3];
bool vis[N][N][3];
ll dp(int l,int r,int t){
    if(vis[l][r][t]) return memo[l][r][t];
    if(l>r) return 0LL;
    ll ans;
    if(t==0){
        ans=max(a[l]+dp(l+1,r,1),a[r]+dp(l,r-1,1));
    }else{
        ans=min(-a[l]+dp(l+1,r,0),-a[r]+dp(l,r-1,0));
    }
    vis[l][r][t]=true;
    return memo[l][r][t]=ans;
    
}
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    cout<<dp(0,n-1,0)<<"\n";
  
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out= new PrintWriter(System.out);
		String s= in.next();
		s= s.replaceAll(",", " ");
		out.println(s);
		out.close();
		
		
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 8400
while True:
    d,e = map(int,input().split())
    if d==e==0: break
    r = []
    for x in range(int(d/2+1)):
        r += [abs((x**2+(d-x)**2)**0.5-e)]
    print(min(r) if min(r)%1!=0 else int(min(r)))

Measured memory_bytes: 7564
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    _ _ 

    dp[i][j][one_of_previous_number_is_lower] = count of remainder j up to i-th digit, 0 <= j < D

    dp[i][(j+digit)%D][True] += dp[i-1][j][True] + dp[i-1][j][False] digit < K[i]
    dp[i][(j+digit)%D][False] += dp[i-1][j][False]        digit == K[i]
    """
    K = list(map(int, input().strip()))
    D = read_int()
    dp = [[0, 0] for _ in range(D)]
    dp[0][0] = 1
    modulo = 10**9+7
    for i in range(len(K)):
        new_dp = [[0, 0] for _ in range(D)]
        for j in range(D):
            for digit in range(10):
                new_dp[(j+digit)%D][True] += dp[j][True]
                if digit < K[i]:
                    new_dp[(j+digit)%D][True] += dp[j][False]
                if digit == K[i]:
                    new_dp[(j+digit)%D][False] += dp[j][False]
                new_dp[(j+digit)%D][False] %= modulo
                new_dp[(j+digit)%D][True] %= modulo
        dp = new_dp
    return (dp[0][0]+dp[0][1]-1)%modulo


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 43500
import java.util.Scanner;
 
class Main {
	int n;
	int[] h;
	int[] cost;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
	}
	Main(Scanner sc){
		n = sc.nextInt();
		h = new int[n];
		cost = new int[n];
		for(int i = 0; i < n;i++){
			h[i] = sc.nextInt();
			cost[i] = Integer.MAX_VALUE;
		}
		cost[0] = 0;
	}
	int cntString(String str,char target){
		int cnt = 0;
		for(char s : str.toCharArray()){
			if(s == target){
				cnt++;
			}
		}
		return cnt;
	}
	void solve(){
		for(int i=1;i < n;i++){
			cost[i] = Math.min(cost[i-1]+Math.abs(h[i]-h[i-1]), cost[i]);
			if(i>1){
				cost[i] = Math.min(cost[i-2]+Math.abs(h[i]-h[i-2]), cost[i]);
			}
		}
		System.out.println(cost[n-1]);
	}
}


Measured memory_bytes: 59088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    set<int> num;
    int N, K;
    cin >> N >> K;
    vector<bool> D(10, true);
    rep(i, K) {
        int d;
        cin >> d;
        D[d] = false;
    }

    repd(i, N, 100001) {
        int tmp = i;
        bool flag = true;
        while (tmp > 0) {
            int ch = tmp % 10;
            if (!D[ch]) {
                flag = false;
                break;
            }
            tmp /= 10;
        }
        if (flag) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/*氏名：保坂優介, 学籍番号：200441141
  概要：三角形の面積、周、高さを求める*/

#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979

int main(void)
{
    double a, b, C, S, L, h;        //変数の宣言

    scanf("%lf %lf %lf", &a, &b, &C);       //入力

    C = PI * (C / 180);     //計算
    S = 0.5 * a * b * sin(C);
    L = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C)) + a + b;
    h = b * sin(C);

    printf("%lf\n%lf\n%lf", S, L, h);       //表示

    return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  int first, last;
  
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'A'){
      first = i;
      break;
    }
  }
  
  for(int i = s.size() - 1; i >= 0; i--){
    if(s.at(i) == 'Z'){
      last = i;
      break;
    }
  }
  
  cout << last - first + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
#define drep(i,x,y) for(int i=(x);i>=(y);--i)
inline int read(){
	char ch=getchar();int x=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
char s[500010];
int n,a[5000010];
inline bool check(int x){
	memset(a,0,sizeof(a));
	rep(i,1,n)a[i]=(s[i]-'0')*9;
	a[1]+=9*x;
	int sum=0;
	rep(i,1,max(n+10,9*x)){
		if(a[i]>9){
			a[i+1]+=a[i]/10;
			a[i]%=10;
		}
		sum+=a[i];
	}
	return sum<=9*x;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n/2){
		swap(s[i],s[n-i+1]);
	}
	int l=1,r=500000,ans;
	while(l<=r){
		int mid=(l+r)/2;
		if(check(mid)){
			r=(ans=mid)-1;
		}
		else l=mid+1;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 20352
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var n = parseInt(input);

var b = false;
for (var i = 1; i <= 9; i++) {
    if (n % i == 0 && n / i <= 9) {
        b = true;
        break;
    }
}
console.log(b ? "Yes" : "No");


Measured memory_bytes: 21064
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  int h, w;
  cin >> h >> w;
  int ch, cw, dh, dw;
  cin >> ch >> cw >> dh >> dw;
  vector<string> s(h);
  REP(i, h) { cin >> s[i]; }
  ch--;
  cw--;
  dh--;
  dw--;

  vector<vector<int>> dp(h, vi(w, 50000000));
  using pii = pair<int, pair<int, int>>;
  priority_queue<pii, vector<pii>, greater<pii>> q;

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

  q.push({0, {ch, cw}});
  auto isIn = [&](int i, int j) -> bool { return 0 <= i && i < h && 0 <= j && j < w; };
  while (!q.empty()) {
    auto [score, pos] = q.top();
    auto [i, j] = pos;
    q.pop();
    if (dp[i][j] <= score)
      continue;
    dp[i][j] = score;
    REP(k, 4) {
      int ni = i + dx[k], nj = j + dy[k];
      if (isIn(ni, nj) && s[ni][nj] == '.' && dp[ni][nj] > dp[i][j]) {
        q.push({score, {ni, nj}});
      }
    }
    for (int di = -2; di <= 2; di++) {
      for (int dj = -2; dj <= 2; dj++) {
        int ni = i + di, nj = j + dj;
        if (isIn(ni, nj) && s[ni][nj] == '.' && dp[ni][nj] > dp[i][j] + 1) {
          q.push({score + 1, {ni, nj}});
        }
      }
    }
  }
  if (dp[dh][dw] == 50000000) {
    cout << -1 << endl;
  } else {
    cout << dp[dh][dw] << endl;
  }

  return 0;
}


Measured memory_bytes: 10668
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define PI 3.14159265358979323846264338327950288419716939937
#define mp make_pair
#define lc (long long)
using namespace std;


int main() {
	int n, inp;
	int ctr1[100005];
	int ctr2[100005];
	cin>>n;
	for(int i = 0;i <= 100000;i ++){
		ctr1[i]=ctr2[i]=0;
	}
	for(int i = 0;i < n;i ++){
		cin>>inp;
		if(i&1){
			ctr1[inp]++;
		}else{
			ctr2[inp]++;
		}
	}
	int max1=0, max2=0;
	int ind1, ind2;
	for(int i = 0;i <= 100000;i ++){
		if(max1<ctr1[i]){
			max1=ctr1[i];
			ind1=i;
		}
		if(max2<ctr2[i]){
			max2=ctr2[i];
			ind2=i;
		}
	}
	if(ind1==ind2){
		int br=100000;
		for(int i = 0;i < ind1;i ++){
			br=min(br,n-ctr1[i]-ctr2[ind2]);
			br=min(br,n-ctr1[ind1]-ctr2[i]);
		}
		for(int i = ind1+1;i < n;i ++){
			br=min(br,n-ctr1[i]-ctr2[ind2]);
			br=min(br,n-ctr1[ind1]-ctr2[i]);
		}
		cout<<br<<"\n";
		return 0;
	}
	cout<<(n-max1-max2)<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}


int main(){
  long long X, Y, a, b, c, maxa;
  long long p[100000],q[100000], r[300000];

  scanf("%lld%lld%lld%lld%lld",&X, &Y, &a, &b, &c);


  for (int i = 0; i <a; i++)
  {
      scanf("%lld", p + i);
  }
  for (int i = 0; i <b; i++)
  {
      scanf("%lld", q + i);
  }
  for (int i = 0; i <c; i++)
  {
      scanf("%lld", r + i);
  }

   qsort(p, a, sizeof(long long), cmpnum);
   qsort(q, b, sizeof(long long), cmpnum);

  
  for (int i = 0; i < X; i++)
  {
      r[c + i] = p[i];
  }  
  for (int i = 0; i < Y; i++)
  {
      r[c + X + i] = q[i];
  }
  
  qsort(r, c+X+Y, sizeof(long long), cmpnum);

  maxa = 0;

   for (int i = 0; i < X+Y; i++)
  {
      maxa += r[i];
  }  

  
   printf("%lld\n", maxa);
  

  return 0;
}

Measured memory_bytes: 6892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var a = ReadInts();
            var ans = 0;
            for (int i = 1; i < n; i++)
            {
                if (a[i] == a[i - 1])
                {
                    ans++;
                    a[i] = 0;
                }
            }
            WriteLine(ans);

        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 13140
n, k = map(int, input().split())
s = input()

from itertools import groupby, accumulate

def gen(s):
  if s[:1] == '0':
  	yield 0
  for ke, g in groupby(s):
    yield len(list(g))
  if s[-1:] == '0':
    yield 0


mc = 0
acc = list(accumulate(gen(s)))
r = 2 * k + 1
if len(acc) < r:
  mc = n
else:
  for i in range(0, len(acc)-r+1, 2):
    if i == 0:
      mc = max(mc, acc[i+r-1])
    else:
      mc = max(mc, acc[i+r-1] - acc[i-1])
print(mc)


Measured memory_bytes: 7180
#include <stdio.h>
#include <math.h>
  
int main(void)
{
 int xp1, yp1, xp2, yp2;
 int q;
 int xp, yp;
 int i = 1;
 double x, y;
 double k;
 double l;
  
 scanf("%d%d%d%d", &xp1, &yp1, &xp2, &yp2);
 scanf("%d", &q);
  
 do {
 scanf("%d%d", &xp, &yp);
  
 k = (xp - xp1) * (xp2 - xp1) +(yp - yp1) * (yp2 - yp1);
 l = (xp2 -xp1) * (xp2 - xp1) + (yp2 - yp1) * (yp2 -yp1);
 x = xp1 + k / l * (xp2 - xp1);
 y = yp1 + k / l * (yp2 - yp1);
  
 printf("%.10f %.10f\n", x, y);
  
 i = i++;
 } while(i <= q);
  
 return 0;
  
}

Measured memory_bytes: 640