akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define int long long

const int NN = 10000000;

int prime[NN];
bool is_prime[NN + 1];



int solve(int n)
{
	int p = 0;
	REP(i, n)is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n ; i++){
		if (is_prime[i]){
			prime[p++] = i;
			for (int j = 2*i; j <= n; j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}

signed main(){
	solve(NN);

	while (1){

		vector<int> ar;	
		int a = 0;
		int N, P;
		cin >> N >> P;

		if (N == -1 && P == -1)break;

		REP(i, NN){
			if (prime[a] > N)break;
			a++;
		}

		REP(i, 100){
			for (int j = i; j < 100;++j){
				int x = prime[a + i] + prime[a + j];
				ar.push_back(x);
			}
		}

		sort(ar.begin(), ar.end());

		cout << ar[P - 1] << endl;

	}
	return 0;

}

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

int main(){
    string s; cin >> s;
    int ans = 100000000;
    int n = (int)s.size();
    //cout << n << endl;
    bool flag = true;
    for(int i = 0; i < n - 1; i++){
        if(s[i] != s[i + 1]){
            flag = false;
            ans = min(ans, max(i + 1, n - i - 1));
        }
    }

    if(flag) cout << n << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string ATGC = "AGCT";

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    char in;
    cin >> in;
    for(int i = 0; i < 4; i++) {
        if(ATGC[i] == in) cout << ATGC[3 - i] << endl;
    }
    return 0;
}


Measured memory_bytes: 764
def resolve():
    ss = input()

    tmp1 = ss[0]
    tmp2 = ""

    cnt1 = 1
    cnt2 = 0
    for s in ss[1:]:
        if s == tmp1:
            cnt1 += 1
        else:
            if tmp2 == "":
                tmp2 = s
                cnt2 = 1
            else:
                if tmp2 == s:
                    cnt2 += 1

    if cnt1 == 2 and cnt2 == 2:
        print('Yes')
    else:
        print('No')
        
resolve()

Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main(){
    int K;
    long A[100000];
    cin >> K;
    for(int i = 0; i < K; i++){
        cin >> A[i];
    }
    long m = 2, M = 2;
    if(A[K-1] != 2){
        cout << -1 << endl;
        return 0;
    }
    for(int i = K-2; i >= 0; i--){
        if(m%A[i] == 0){
            m = (m/A[i])*A[i];
            M = ((M+A[i+1]-1)/A[i])*A[i];
        }else{
            m = (m/A[i]+1)*A[i];
            M = ((M+A[i+1]-1)/A[i])*A[i];
            if(M < m){
                cout << -1 << endl;
                return 0;
            }
            if(m == 0) m = M;
        }
        //cout << m << ' ' << M << endl;
    }
    cout << m << ' ' << M+A[0]-1 << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string s;
    cin >> s;
    for(int i = 0; i <= 1; i++){
        if(s[i] == s[i+1] && s[i+1] == s[i+2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
int main(){
  int h,w;
  cin >> h >> w;
  int count = 0;

  for (int i = 1; i<=h; i++){
    for(int j=1; j<=w; j++){
      char c;
      cin >> c;
      if(c == '#'){
        count++;
      }
    }
  }
  if(count == h+w-1){
    cout << "Possible\n";
  }else{
    cout << "Impossible\n";
  }
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << max(a,b - 1) + max(a - 1,b) << endl;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
    "strings"
)

func main() {
    var str string
    fmt.Scan(&str)
    str = strings.Replace(str, "dream", "A", -1)
    str = strings.Replace(str, "erase", "B", -1)
    str = strings.Replace(str, "Aer", "", -1)
    str = strings.Replace(str, "Br", "", -1)
    str = strings.Replace(str, "A", "", -1)
    str = strings.Replace(str, "B", "", -1)
    if str == "" {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N, K;
    cin >> N >> K;

    LL ans = 0;
    FOR (b, K + 1, N + 1)
    {
        ans += (N / b) * (b - K);
        ans += max(0, N - (b * (N / b) + max(0, K - 1)));
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807LL;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<=i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n-1)
#define append(a)      push_back(a)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {cin.tie(0),ios::sync_with_stdio(0);}

ll N,X,x,s;

signed main(){
    cin>>N>>X;
    rep(i,N){
        cin>>x;
        if(i){
            s=gcd(s,x-X);
        }
        else{
            s=x-X;
        }
    }
    cout<<abs(s)<<endl;

}
//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define F first
#define S second

typedef long long ll;
using namespace std;

int n, a, ans;
int main()
{
    cin >> n;
    while (n--) {
        cin >> a;
        ans += a - 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod= 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e15;
const int inf = 2e9;
const int nmax = 5e5+10;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

bool vis[nmax];
int n;

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

    string s;
    cin>>s;

    n = s.size();
    vector<int>v(n+1);
    queue<int>q;

    for(int i=1; i<s.size(); i++){
        if(s[i-1] == '>' and s[i] == '<'){
            vis[i] = true;
            q.push(i);
        }
    }
    if(s[0] == '<') {
		vis[0] = true;
		q.push(0);
    }
    if(s[n-1] == '>' ){
        vis[n] = true;
        q.push(n);
    }

    while(!q.empty()){
        int u = q.front();
        q.pop();
        if(u-1>=0 and s[u-1] == '>'){
            v[u-1] = v[u] + 1;
            q.push(u-1);
        }
        if(u+1<=n  and s[u]=='<'){
            v[u+1] = v[u] + 1;
            q.push(u+1);
        }
    }

    ll ans = 0;
    for(int x : v){
//		cout<<x<<endl;
		ans += x;
    }
    cout<<ans;

}


Measured memory_bytes: 4252
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) int(x.size())
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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 pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	string s, t;
	cin >> s >> t;
	set<char>se;
	for (auto i : s)se.insert(i);
	for (auto i : t) {
		if (!se.count(i)) {
			cout << -1 << endl;
			return 0;
		}
	}

	vector<vector<int>>v(26);
	rep(i, s.size()) {
		int n = (int)s[i] - (int)'a';
		v[n].push_back(i + 1);
	}
	rep(i, s.size()) {
		int n = (int)s[i] - (int)'a';
		v[n].push_back(i + 1 + s.size());
	}

	int ans = 0;
	int pre = 0;
	int SLEN = s.size();
	int TLEN = t.size();
	rep(i, TLEN) {
		int n = (int)t[i] - (int)'a';
		int now = *lower_bound(v[n].begin(), v[n].end(), pre + 1);
		ans += now - pre;
		if (now > SLEN)pre = now - SLEN;
		else pre = now;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5704
lst = [[int(i) for i in input().split()] for _ in range(3)]
lst1 = [lst[1][i] - lst[0][i] for i in range(3)]
lst2 = [lst[2][i] - lst[0][i] for i in range(3)]
if len(set(lst1)) == 1 and len(set(lst2)) == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
N = int(input())

S = []
for _ in range(N):
    tmp=sorted(input())
    S.append(tmp)

for i in range(len(S)):
    S[i]=''.join(S[i])

import collections
from math import factorial

res=0
dic = {}
for tmp in S:
    if tmp in dic.keys():
        res+=dic[tmp]
        dic[tmp]+=1
    else:
        dic[tmp]=1

print(int(res))

Measured memory_bytes: 24464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define v_inputrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する


int main(){
    char a,b;
    cin >> a >> b;
    if(a==b){cout<<"H";}
    else{cout<<"D";}
}

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

int main() {
	int n;
	cin>>n;
	vector<vector<int>> v(n, vector<int> (3,0));
	for(int i=0;i<n;i++) {
		cin>>v[i][0]>>v[i][1]>>v[i][2];
	}
	vector<vector<int>> dp(n, vector<int> (3,0));
	for(int i=0;i<n;i++) {
		for(int j=0;j<3;j++) {
			if(i==0) {
				dp[i][j] = v[i][j];
			} else {
				if(j==0) {
					dp[i][j] = v[i][j] + max(dp[i-1][j+1], dp[i-1][j+2]);
				} else if(j==1) {
					dp[i][j] = v[i][j] + max(dp[i-1][j-1], dp[i-1][j+1]);
				} else {
					dp[i][j] = v[i][j] + max(dp[i-1][j-2], dp[i-1][j-1]);
				}
			}
		}
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
	return 0;
}

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

int main()
{
	char s;
	cin >> s;
	if ((s == 'a') || (s == 'i') || (s == 'u') ||
		(s == 'e') || (s == 'o')) {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	ll x;
	cin >> x;
	unsigned long long now = 100;
	ll ans = 0;
	while (now < x) {
		ans++;
		now = now * 1.01;
		//cout << now << endl;
	}
	cout << ans << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n){
        ll a;
        cin >> a;
        ll tmp = 0;
        while(a%2 == 0){
            tmp += 1;
            a /= 2;
        }
        ans += tmp;
    }
    cout << ans << endl;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a + b == c || b + c == a || c + a == b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3552
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

void solve() {

	int n;
	cin >> n;

	vi a(100001, 0), b(100001, 0);

	REP(i, n) {
		int tmp;
		cin >> tmp;
		if (i & 1) {
			b[tmp]++;
		}
		else {
			a[tmp]++;
		}
	}

	int maxa = 0, maxb = 0;
	FOR(i, 1, 100000) {
		if (a[maxa] < a[i]) maxa = i;
		if (b[maxb] < b[i]) maxb = i;
	}
	sort(ALL(a), greater<int>());
	sort(ALL(b), greater<int>());

	int cnt = 0;

	if (maxa == maxb) {
		cnt = a[0] + b[1] > a[1] + b[0] ? n - (a[0] + b[1]) : n - (a[1] + b[0]);
	}
	else {
		cnt = n - (a[0] + b[0]);
	}

	out(cnt);

	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 1024
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(key=lambda x: -x[2])

for cx in range(101):
    for cy in range(101):
        ch = None
        for x, y, h in xyh:
            t = h + abs(cx - x) + abs(cy - y)
            if h > 0:
                if ch is not None and t != ch:
                    break
                ch = t
            else:
                if t < ch:
                    break
        else:
            print(cx, cy, ch)
            exit()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=100005;
int h[N],ne[N<<1],to[N<<1],sum[N],vis[N],k[N],b[N];
int n,m,tot,ss,tt,js,all;LL ans;
void add(int x,int y) {to[++tot]=y,ne[tot]=h[x],h[x]=tot;}
void dfs1(int x,int las) {
	sum[x]=-sum[las],all+=sum[x],vis[x]=1;
	for(RI i=h[x];i;i=ne[i]) {
		if(to[i]==las) continue;
		if(vis[to[i]]) tt=to[i],ss=x;
		else dfs1(to[i],x);
	}
}
void dfs2(int x,int las) {
	for(RI i=h[x];i;i=ne[i]) {
		if(to[i]==las||(x==ss&&to[i]==tt)||(x==tt&&to[i]==ss)) continue;
		dfs2(to[i],x);
		sum[x]+=sum[to[i]],k[x]+=k[to[i]];
	}
}
void work1() {
	if(all) {puts("-1");return;}
	dfs2(1,0);for(RI i=1;i<=n;++i) ans+=abs(sum[i]);
	printf("%lld\n",ans);
}
void work2() {
	if(all&1) {puts("-1");return;}
	sum[ss]-=all/2,sum[tt]-=all/2;
	ans+=abs(all/2);
	dfs2(1,0);for(RI i=1;i<=n;++i) ans+=abs(sum[i]);
	printf("%lld\n",ans);
}
void work3() {
	if(all) {puts("-1");return;}
	++k[ss],--k[tt],dfs2(1,0);
	b[++js]=0;
	for(RI i=1;i<=n;++i)
		if(!k[i]) ans+=abs(sum[i]);
		else if(k[i]==1) b[++js]=-sum[i];
		else b[++js]=sum[i];
	sort(b+1,b+1+js);
	int x=b[(js+1)/2];
	for(RI i=1;i<=js;++i) ans+=abs(x-b[i]);
	printf("%lld\n",ans);
}
int main()
{
	int x,y;
	n=read(),m=read();
	for(RI i=1;i<=m;++i) x=read(),y=read(),add(x,y),add(y,x);
	sum[0]=-1,dfs1(1,0);
	if(m==n-1) work1();
	else if(sum[ss]==sum[tt]) work2();
	else work3();
	return 0;
}

Measured memory_bytes: 8448
n = int(input())
lis = list(map(int,input().split()))
numm = 0
ans = 0
nu = 10 ** 9
for num in lis:
  nu = min(nu,abs(num))
  ans += abs(num)
  if num < 0:
    numm += 1
if numm % 2 == 1:
  print(ans-nu*2)
else:
  print(ans)

Measured memory_bytes: 15020
N = int(input())
As = list(map(int,input().split()))
Q = int(input())

count_array = [0]*(10**5+1)
for i in range(N):
    count_array[As[i]] += 1

sum = 0
for i in range(len(As)):
    sum += As[i]

for i in range(Q):
    x,y = map(int,input().split())
    sum += count_array[x]*(y-x)
    print(sum)
    count_array[y] += count_array[x]
    count_array[x] = 0


Measured memory_bytes: 20876
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  vector<int> as(n+1),bs(n+1);
  vector<int> at(m+1),bt(m+1);
  for(int i = 0; i < n; ++i){
    as[i+1]=as[i]+ (s[i]=='A');
    bs[i+1]=bs[i]+ (s[i]=='B');
  }
  for(int i = 0; i < m; ++i){
    at[i+1]=at[i]+ (t[i]=='A');
    bt[i+1]=bt[i]+ (t[i]=='B');
  }
  
  int q;cin >> q;
  
  for(int i = 0; i < q; ++i){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    --a;--c;
    int s1 = as[b]-as[a];
    int s2 = bs[b]-bs[a];
    int t1 = at[d]-at[c];
    int t2 = bt[d]-bt[c];
    s1 += 2 * s2;
    t1 += 2 * t2;
    string ans = "NO";
    if(abs(s1-t1)%3==0) ans= "YES";
    cout << ans << endl;
  }
}



Measured memory_bytes: 2432
h, w = map(int,input().split())
stay_x = []
stay_y = []
grid = []

for y in range(h):
    a = input()
    grid.append(a)
    remove = True
    for x in range(w):
        if a[x] == "#":
            remove = False
            if x not in stay_x:
                stay_x.append(x)        
    if remove != True:
        stay_y.append(y)
stay_x.sort()
for y in stay_y:
    out = ""
    for x in stay_x:
        out += grid[y][x]
    print(out)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>

int main(){
    double a, b, c;
    std::cin >> a >> b >> c;

    double h = b * std::sin(M_PI * c/180);
    double d = std::sqrt(std::pow(a, 2) + std::pow(b,2) - 2 * a * b * std::cos(M_PI * c/180));
    double s = a * h / 2;

    std::cout << std::fixed;
    std::cout << std::setprecision(4) << s << std::endl;
    std::cout << std::setprecision(4) << a + b + d << std::endl;
    std::cout << std::setprecision(4) << h << std::endl;

    return 0;
}


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

int main()
{
  int n,q;
  for(;cin>>n>>q,n;)
    {
      string name[n];
      int byear[n];
      int wyear[n];
      for(int i=0;i<n;i++)
	  cin>>name[i]>>byear[i]>>wyear[i];
      
      for(int i=0;i<q;i++)
	{
	  bool flag=true;
	  int qe;
	  cin>>qe;
	  for(int x=0;x<n;x++)
	    {
	      if(qe<=wyear[x] &&qe>wyear[x]-byear[x])
		{
		  cout<<name[x]<<" "<<qe-(wyear[x]-byear[x])<<endl;
		  flag=false;
		  break;
		}
	    }
	  if(flag)
	    cout<<"Unknown"<<endl;
	}
      

    }

}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int a;
int f(long p,long q,int now,int low,int less)
{
	if(less==0)
	{
		return p==0;
	}
	else if(p==0)
	{
		return 1;
	}
	int ans=0;
	for(int i=low;i*now<=a;i++)
	{
		if(p*i<q)continue;
		ans+=f(p*i-q,q*i,now*i,i,less-1);
	}
	return ans;
}
main()
{
	int p,q,n;
	while(cin>>p>>q>>a>>n,a)
	{
		cout<<f(p,q,1,1,n)<<endl;
	}
}



Measured memory_bytes: 2984
#include<stdio.h>
#define N 105
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[N][N];
int color[N],d[N],f[N],tt;
void dfs_visit(int u){
     int v;
     color[u]=GRAY;
     d[u]=++tt;
     for(v=1;v<=n;v++)
     {
         if(M[u][v]==0)continue;
         if(color[v]==WHITE){
            dfs_visit(v);
         }
     }
     color[u]=BLACK;
         f[u]=++tt;
}
void dfs(){
     int u;
     for(u=1;u<=n;u++)color[u]=WHITE;
     tt=0;
     for(u=1;u<=n;u++)
     {
         if(color[u]==WHITE)dfs_visit(u);
     }
     for(u=1;u<=n;u++){
        printf("%d %d %d\n",u,d[u],f[u]);
     }
}
int main()
{
    int u,v,k,i,j;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)M[i][j]=0;
    }
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&u,&k);
        //u--;
        for(j=1;j<=k;j++)
        {
            scanf("%d",&v);
        //v--;
            M[u][v]=1;
        }
    }
    dfs();
    return 0;
}

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        n: usize,
        m: usize,
        a: [usize; n]
    }
    let mut res = a.clone();
    res.sort();
    let mut result = true;
    for i in (n-m..n).rev(){
        result &= if 4*m*res[i] >= res.iter().fold(0, |sum, a| sum + a) {true} else {false};
    }
    print!("{}", if result {"Yes"} else {"No"}.to_string())
}


Measured memory_bytes: 4352
// Aizu 1130: Red and Black
// 2017.9.13 bal4u@uu

#include <stdio.h>
#include <string.h>

char map[22][22], mk[22][22];
int que[500][2], top, end;
int m[4][2] = {{1,0},{-1,0},{0,-1},{0,1}};

int main()
{
	int w, h, i, r, c, r2, c2, ans;
	
	while (scanf("%d%d", &w, &h) && w) {
		memset(mk, 0, sizeof(mk));
		for (i = 0, r = 0; r < h; r++) {
			scanf("%s", map[r]);
			if (!i) for (c = 0; c < w; c++) if (map[r][c] == '@') {
				que[0][0] = r, que[0][1] = c; mk[r][c] = 1, top = 0, end = 1, i = 1;
			}
		}
		while (top < end) {
			r = que[top][0], c = que[top++][1];
			for (i = 0; i < 4; i++) {
				r2 = r + m[i][0], c2 = c + m[i][1];
				if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || map[r2][c2] == '#') continue;
				if (mk[r2][c2]) continue;
				mk[r2][c2] = 1;
				que[end][0] = r2, que[end++][1] = c2;
			}
		}
		for (ans = 0, r = 0; r < h; r++) for (c = 0; c < w; c++) ans += mk[r][c];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1756
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let (a, b): (u32, u32) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        (sc.next(), sc.next())
    };
    if a > b {
        println!("{}", a - 1);
    } else {
        println!("{}", a);
    }
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	for i := 0; i < N; i++ {
		A[i] -= i + 1
	}
	sort.Ints(A)
	b := A[N/2]
	ans := 0
	for i := 0; i < N; i++ {
		ans += Abs(A[i] - b)
	}
	fmt.Println(ans)
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

void func(ll *a, ll *b, ll *c){
  ll ah = *a/2;
  ll bh = *b/2;
  ll ch = *c/2;
  *a = bh+ch;
  *b = ah+ch;
  *c = ah+bh;
}

//0->0
//1->1
//2->2
//3->2
//4->3
//5->3
//6->4

int main(){
  string s; cin>>s;
  int N = s.size();
  int r = N+1;
  for(char c='a'; c<='z'; ++c){
    int s_idx=-1;
    int e_idx=-1;
    REP(i,N){ if(s[i]==c){ s_idx=i;break;} }
    REPR(i,N-1){ if(s[i]==c){ e_idx=i;break;} }
    if(s_idx==-1){continue;}
    else{
      int r_c = max(s_idx,N-e_idx-1);
      int dis = 0;
      for(int i=s_idx+1;i<e_idx;++i){
        if(s[i]==c){
          if(dis>0){r_c = max(dis,r_c); dis=0;}
        }
        else{ ++dis; }
      }
      if(dis>0){ r_c = max(dis,r_c); }
      r = min(r_c,r);
    }
  }
  cout << r <<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100001
using namespace std;
typedef long long ll;

int n;
int a[MAX];

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    scanf("%d", a+i);

  sort(a, a+n);
  reverse(a, a+n);
  int max_val, max_cnt;
  max_val = max_cnt = 0;

  int i, j;
  vector<ll> sides;
  for(i = 0; i < n; i++) {
    int cnt = 0;
    for(j = i; a[j] == a[i]; j++)
      cnt++;

    if(cnt >= 2) sides.push_back(a[i]);
    if(cnt >= 4) sides.push_back(a[i]);
    i = j-1;
  }


  if(sides.size() >= 2) printf("%lld\n", sides[0] * sides[1]);
  else                  printf("0\n");
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<ll>b(n);
	if (n % 2 == 0) {
		b[n / 2] = a[0];
		int j = 1;
		for (int i = 1; i <= n; i++) {
			b[(n / 2) - j] = a[i];
			i++;
			if (i == n) {
				break;
			}
			b[(n / 2) + j] = a[i];
			j++;
		}
	}
	else {
		b[n / 2] = a[0];
		int j = 1;
		for (int i = 1; i < n; i++) {
			b[(n / 2) + j] = a[i];
			i++;
			if (i == n) {
				break;
			}
			b[(n / 2) - j] = a[i];
			j++;
		}
	}
	REP(i, n) {
		cout << b[i] << " ";
	}
	cout << endl;
	return 0;
}

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

int main() {
	string s, t; cin >> s >> t;

	bool ans = false;
	for (int i = 0; i < s.size(); i++) {
		if (s == t) {
			ans = true;
			break;
		}

		s = s.back() + s.substr(0, s.size() - 1);
	}

	cout << (ans == true ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;




int main(){
      //memset( par, -1, sizeof par );
    int n;
    cin>>n;
    int a[n];
    ll ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(i!=j){
                ans+=a[i]*a[j];
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f(i,l,r) for(int i=l;i<=r;i++)
#define debug(x) cout<<#x<<'='<<(x)<<endl
using namespace std;
template<class T> bool maxs(T& a,T& b)
{
	if(a<b)
	{
		T t;
		t=a;
		a=b;
		b=t;
		return true;
	}
	return false;
}

template<class T> T maxi(T& a,T b)
{
	if(a<b)
	{
		a=b;	
		return b;
	}
	return a;
}
template<class T> T mini(T& a,T b)
{
	if(a>b)
	{
		a=b;
		return b;
	}
	return a;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll a[n+1][3];
	f(i,1,n)
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	ll dp[n+1][3];
	dp[1][0]=a[1][0];
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	f(i,2,n)
	{
		dp[i][0]=dp[i][1]=dp[i][2]=0;
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#define MY_TAN(x1,y1,x2,y2) (((y2)-(y1)) / ((x2)-(x1)))

int main(){
	double x[4];
	double y[4];
	int num,i,j;
	scanf("%d",&num);
	for(i=0;i<num;i++){
		for(j=0;j<4;j++){
			scanf("%lf %lf",&x[j],&y[j]);
		}
		if(x[0]==x[1] || x[2]==x[3]){
			if(x[0]==x[1] && x[2]==x[3]){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
			continue;
		}
		if(MY_TAN(x[0],y[0],x[1],y[1]) == MY_TAN(x[2],y[2],x[3],y[3])){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	
	return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> T(H,vector<char>(W));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++) cin >> T[i][j];
  }
  int count=0,k_c=0;
  vector<bool> Hc(W,false),Wc(H,false);
  
  for(int i=0;i<H;i++){
    count = 0;
    for(int j=0;j<W;j++){
      if(i==0){
        k_c = count;
        count = 0;
        for(int k=0;k<H;k++)if(T[k][j] == '.')count++;
        if(count == H)Hc[j]=true;
        count=k_c;
      }
      if(T[i][j]=='.')count++;
    }
    if(count == W)Wc[i]=true;
  }
  
  for(int i=0;i<H;i++){
    if(Wc[i])continue;
    for(int j=0;j<W;j++){
      if(Hc[j])continue;
      cout << T[i][j];
    }
    cout << endl;
  }
  
  return 0;
}




Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s) {
    int ans = 0;
    for (int i = 0; i < s.length - 1; i++) {
        int cnt = 0;
        foreach (c; 'a'..'z' + 1) {
            if (s[0..i+1].canFind(c) && s[i+1..$].canFind(c)) {
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }
    return ans;
}
void main() {
    readint;
    auto s = readln.chomp;
    writeln(calc(s));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>

using ll = long long;

#define rep(i, n) for(int i=0;i<(n);++i)
#define chmin(x,y) x=std::min(x,y)

constexpr ll INF {1000000000000};

int main(int argc, char** argv) {
  ll N, K;
  std::cin >> N >> K;
  std::vector<ll> H(N);
  rep(i,N) std::cin >> H[i];
  std::vector<ll> dp(N, INF);
  dp[0] = 0;

  rep(i, N) {
    for (auto j = 1;j <= K;++j) {
      ll p = i+j;
      if (p >= N) break;
      chmin(dp[p], dp[i]+std::abs(H[i]-H[p]));
    }
  }
  std::cout << dp[N-1] << '\n';
}


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

using namespace std;
using namespace __gnu_pbds;

#define ops cout<<"ops"<<endl;
#define freopens freopen("dishes.in", "r", stdin);freopen("dishes.out", "w", stdout);
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define DIM 100007
#define DIMM 10000007
#define INF 10000000000000000007.0
#define X 200000
#define epc 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007
const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> myset;

ll a,b,t;

int main()
{
    //ops
    //freopens
    fast

    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>a>>b>>t;
    cout<<t/a*b<<endl;
    return 0;
}


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

int main()
{
    int N;
    double num[100];
    double ans[100];
    int i;
    int k;
    int a;
    double Ans;
    k=0;
    Ans=0;
    cin >> N;
    for( i=0 ; i<N ; i=i+1 )
    {
        cin >> num[i];
    }
	while(k<N){
		Ans=Ans+1/num[k];
		k+=1;
	}
	Ans=1/Ans;
	cout << Ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	int n;
	cin >> n;

	set<string> ids;
	REP( i, 0, n )
	{
		string tmp;
		cin >> tmp;
		ids.insert( tmp );
	}

	int m;
	cin >> m;
	bool opend = false;
	REP( i, 0, m )
	{
		string user;
		cin >> user;

		if ( EXIST( ids, user ) )
		{
			cout << ( opend ? "Closed" : "Opened" ) << " by ";
			opend = !opend;
		}
		else
		{
			cout << "Unknown ";
		}
		cout << user << endl;
	}

	return 0;
}

Measured memory_bytes: 1236
N=int(input())
H=list(map(int,input().split()))
for i in range(N-1):
    if H[i+1]-H[i]>0:
        H[i+1]-=1
    elif H[i+1]-H[i]==0:
        continue
    else:
        print("No")
        exit()
else:
    print("Yes")

Measured memory_bytes: 14252
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;

#define N 100010
int par[N];
int rnk[N];
int weight[N];

void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        weight[i] = 1;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]){
        weight[find(y)] += weight[find(x)];
        par[x] = y;
    }
    else{
        weight[find(x)] += weight[find(y)];
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}

//----------------------------------------------------------------
signed main(){

	ll n;
	cin >> n;
	vector<pair<ll,ll>> q(n);
	rep(i,n)cin >> q[i].fi >> q[i].se;
	SORT(q);
	vector<pair<pair<ll,ll>,ll>> xy(n);
	vector<pair<pair<ll,ll>,ll>> yx(n);
	rep(i,n){
		ll x,y;
		x = q[i].fi;
		y = q[i].se;
		xy[i].se = yx[i].se = i;
		xy[i].fi = MP(x,y);
		yx[i].fi = MP(y,x);
	}
	SORT(xy);
	SORT(yx);

	init(n);
	rep(i,n-1)if(xy[i].fi.fi == xy[i+1].fi.fi)unite(xy[i].se,xy[i+1].se);
	rep(i,n-1)if(yx[i].fi.fi == yx[i+1].fi.fi)unite(yx[i].se,yx[i+1].se);

	unordered_map<ll,pair<ll,pair<set<ll>,set<ll>>>> p; // par x y 
	rep(i,n){
		ll x = xy[i].fi.fi;
		ll y = xy[i].fi.se;
		ll oya = find(i);
		p[oya].fi += 1;
		p[oya].se.fi.insert(x);
		p[oya].se.se.insert(y);
	}
	ll ans = 0;
	for(auto k:p){
		ll x = k.se.se.fi.size();
		ll y = k.se.se.se.size();
		// ll s = k.se.fi;
		ll s = weight[k.fi];
		if(x>=1 && y >= 1)ans += x*y-s;
	}
	cout << ans << endl;

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc131.contest.atcoder.jp/tasks/abc131_f

Measured memory_bytes: 18176
(defun n (s)
  (cond ((eq #\a s) 0)
        ((eq #\b s) 1)
        (t 2)))

(let ((a (make-array 0 :adjustable t
                       :fill-pointer 0))
      (pre 0)
      temp)
     (loop repeat 3 do (vector-push-extend (read-line) a))
     (loop while (not (zerop (length (aref a pre)))) do
           (setf temp (char (aref a pre) 0))
           (setf (aref a pre) (subseq (aref a pre) 1))
           (setf pre (n temp)))
     (princ (cond ((= pre 0) "A")
                  ((= pre 1) "B")
                  (t "C"))))

Measured memory_bytes: 13280
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
alice = []
bob = []
for i in range(n):
    if i%2==0:
        alice.append(a[i])
    else:
        bob.append(a[i])
print(sum(alice) - sum(bob))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main() {
    string S;
    cin >> S;

    int A[S.length()];
    for(int i=0; i<S.length(); i++) A[i] = 0;


    int t = -1, cnt=0;
    bool dir = true;
    for(int i=0; i<S.length(); i++) {
        if(S[i] == 'R') {
            if(dir) {
                cnt++;
            } else {
                cnt = 1;
                dir = true;
            }
        } else {
            if(!dir) {
                A[t - (i - t) % 2]++;
            } else {
                A[i-1] += cnt / 2 + cnt % 2;
                A[i] += cnt / 2 + 1;
                t = i;
                dir = false;
            }
        }
    }

    for(int i=0; i<S.length(); i++) {
        if(i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 999999
using namespace std;
bool prime[1000000]={0};
int main(){
    prime[1]=1;
    for(int i=2;i*i<=1000000;i++){
        if(prime[i]==0){
            for(int j=i;j<1000000;j+=i){
                prime[j]=1;
            }
            prime[i]=0;
        }
    }
    int N;
    while(cin>>N,N){
            int cnt=0;
        for(int i=N+1;i<=N*2;i++){
            if(prime[i]==0)cnt++;
        }
    cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;
const ll INFLL = 1e18l+5;

int main(){
    int N,X,T;
    cin>>N>>X>>T;
    int p;
    p=N/X;
    if(N%X!=0) p+=1;
    cout<<(p)*T;

    
}

Measured memory_bytes: 3604
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
    L = X-500*i
    for j in range(B+1):
        M = L-100*j
        for k in range(C+1):
            if M == 50*k:
                ans += 1
print(ans)

Measured memory_bytes: 3064
def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def cmb(n,r,mod):
    X=1
    Y=1
    for i in range(r):
        X*=n-i
        X%=mod
        Y*=i+1
        Y%=mod
    Y=pow(Y,mod-2,mod)
    X*=Y
    return X%mod

mod=10**9+7
n,a,b=map(int,input().split())
result=pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1
if result<0:
    result+=mod
result%=mod
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v(n);
    ll mr = INF, mlo = -INF, ml = -INF;
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
        chmin(mr, v[i].second);
        chmax(mlo, v[i].second - v[i].first + 1LL);
        chmax(ml, v[i].first);
    }
    ll t = -INF;
    for (int i = 0; i < n; i++) {
        if (v[i].second == mr) {
            chmax(t, v[i].first);
        }
    }
    sort(all(v));
    ll mal = -INF, mir = INF;
    ll res = 0;
    for (int i = n - 1; i >= 0; i--) {
        ll l = v[i].first, r = v[i].second;
        if (l < t) {
            break;
        }
        if (i < n - 1 && l == v[i + 1].first) {
            chmax(mal, l);
            chmin(mir, r);
            continue;
        }
        ll s;
        if (l == ml) {
            s = max(0LL, mr - ml + 1LL);
            s += mlo;
        } else {
            s = max(0LL, mr - l + 1LL);
            s += max(0LL, mir - mal + 1LL);
        }
        chmax(mal, l);
        chmin(mir, r);
        chmax(res, s);
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
int main()
{
	int i,j,k,n,m;
	scanf("%d",&n);
	if(n<1200)
	{
		printf("ABC\n");
	}
	else if(n<2800)
	{
		printf("ARC\n");
	}
	else
	{
		printf("AGC\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
int N,A[21],B[21],C[21];

int main()
{
  int i,j;
  scanf("%d",&N);
  for(i=1;i<N+1;i++)
  {
    scanf("%d",&A[i]);
  }
  for(i=1;i<N+1;i++)
  {
    scanf("%d",&B[i]);
  }
  for(i=1;i<N;i++)
  {
    scanf("%d",&C[i]);
  }
  
  j=0;
  for(i=1;i<N+1;i++)
  {
    j+=B[i];
    
    if(i<N)
    {
      if(A[i+1]==A[i]+1)
      {
        j+=C[A[i]];
        
      }
    }
  }
          
  
  
  printf("%d",j);

  return 0;
}

Measured memory_bytes: 128
import Data.Maybe
import Control.Monad
import qualified Data.Map as M

type Map = M.Map Char Int

setMin :: Char -> Int -> Map -> Map
setMin c count m = case M.lookup c m of
                     Just x  -> if count < x
                                then M.insert c count m
                                else m
                     Nothing -> M.insert c count m

check :: String -> Map -> String -> Map
check [] m _ = m
check (a:as) m s = check as (setMin a count m) s
  where count = length $ filter (==a) s

main :: IO ()
main = do
  n <- readLn
  ss <- replicateM n getLine
  let res = filter ((>0) . snd) . M.toList $ foldl (check ['a'..'z']) M.empty ss
  putStrLn . concat $ map (\x -> replicate (snd x) (fst x)) res

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 a,b,c;
    scanf("%lli%lli%lli",&a,&b,&c);
    i64 ans=0LL;
    for(i64 i=a;i<=b;++i){
        if(c%i==0LL) ++ans;
    }
    printf("%lli\n",ans);
    return 0;
}



Measured memory_bytes: 2108