akhauriyash/Code-Regression huggingface dataset:
// abc134_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    vector<int> origin = A;
    sort(ALL(A));
    int mx = A[N-1];
    if (A[N-2] == mx){
        REP(i, N){
            print(mx);
        }
    } else {
        REP(i, N){
            if (origin[i] == mx){
                print(A[N-2]);
            } else {
                print(mx);
            }
        }
    }


    return 0;
}


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

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

  double odd = 0;

  for (int i = 1; i <= N; i++) {
    if (i % 2 == 1) {
      odd++;
    }
  }

  cout << odd / N << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

char s[1010][1010];

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

	rep(i, H) {
		rep(j, W) {
			int t = (i < B) ^ (j < A);
			s[i][j] = '0' + t;
		}
	}

	rep(i, H) {
		puts(s[i]);
	}

	return 0;
}

Measured memory_bytes: 2176
import math

A, B, H, M = map(int, input().split())

angle_H = 30 * H + 0.5 * M
angle_M = M * 6

diff_angle = abs(angle_H - angle_M)

if diff_angle >= 180:
    diff_angle =  360 - diff_angle
    
    
C2 = A**2 + B**2 - 2*A*B*math.cos(math.radians(diff_angle)) 

print(math.sqrt(C2))

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<typename Monoid>
struct Segment_Tree{
    Monoid ope(Monoid a, Monoid b){
        return a+b;
    }
    const Monoid unit;
    int n;
    vector<Monoid> seg;
    
    Segment_Tree(int N, const Monoid &x) : unit(x){
        n = 1;
        while(n < N) n <<= 1;
        seg.assign(2*n, unit);
    }
    
    void change(int i, const Monoid &x){
        i += n;
        seg[i] = x;
        while(i > 0){
            i /= 2;
            seg[i] = ope(seg[2*i], seg[2*i+1]);
        }
    }

    Monoid query(int a, int b, int i = 1, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return unit;
        if(a <= l && r <= b) return seg[i];
        Monoid vl = query(a, b, 2*i, l, (l+r)/2);
        Monoid vr = query(a, b, 2*i+1, (l+r)/2, r);
        return ope(vl, vr);
    }
    
    Monoid operator [] (int i) const {return seg[n+i];}
    
    void clear(){
        fill(seg.begin(), seg.end(), unit);
    }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    int c[N];
    rep(i, N) {cin >> c[i]; c[i]--;}
    int pos[N];
    fill(pos, pos+N, -1);
    Segment_Tree<int> seg(N, 0);
    vector<pii> q[N+1];
    rep(i, Q){
        int l, r; cin >> l >> r; l--;
        q[r].pb(pii(l, i));
    }
    int ans[Q];
    rep(i, N+1){
        for(auto &e: q[i]){
            ans[e.second] = seg.query(e.first, i);
        }
        if(i == N) break;
        if(pos[c[i]] != -1) seg.change(pos[c[i]], 0);
        pos[c[i]] = i;
        seg.change(i, 1);
    }
    rep(i, Q) cout << ans[i] << endl;
}

Measured memory_bytes: 35312
N,M,X,Y = map(int,input().split())
xns = [int(x) for x in input().split()]
yns = [int(y) for y in input().split()]

if Y - X > 0 and X <= max(xns)  and min(yns) <= Y and min(yns) - max(xns) > 0:
    print("No War")
else:
    print("War")



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	long long a, b;
	cin >> a >> b;

	if(a % b == 0){
		cout << -1 << endl;
	}else{
		while(a % b == 0){
			a+=a;
		}
		cout << a << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;
  cin >> n;
  if(n==1){
    cout << 0 << endl;
    return 0;
  }
  long long i,j;
  vector<long long> p(60,1);
  i=2;
  j=0;
  while(n>=i*i){
    if(n%i==0){
      p.at(j)=i;
      n=n/i;
      j++;
    }else{
      i++;
    }
  }
  p.at(j)=n;
  
  long long s,t,k;
  s=0;
  t=1;
  for(i=1;i<=j+1;i++){
    if(p.at(i)==p.at(i-1)){
      t++;
    }else{
      k=1;
      while(k*(k+1)<=t*2){
        k++;
      }
      s += k-1;
      t=1;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

int gcd(int a, int b){
    if(a % b == 0) return b;
    else return (gcd(b, a%b));
}



int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    for(int i = 0; i < N - 1; i++){
        if(a[i] < a[i + 1]){
            a[i + 1]--;
        }
        if(a[i] > a[i + 1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

void trace(int A[], int N) {
  int i;
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void insertionSort(int A[], int N) {
  int i, v, j;
  for ( i = 1; i < N; i++ ) {
    v = A[i];
    j = i - 1;
    while ( j >= 0 && A[j] > v ) A[j + 1] = A[j--];
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];

  cin >> N;
  for ( i = 0; i < N; i++ ) cin >> A[i];

  trace(A, N);
  insertionSort(A, N);

  return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<Edge>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int N;
Graph G;
vector<int> res;

// vをcに塗る。pはvの親
void dfs(int v,int p,int c) {
  res[v]=c;
  for(auto e:G[v]) {
    if(e.first==p) continue;
    if(e.second & 1) dfs(e.first,v,1-c);
    else dfs(e.first,v,c);
  }
}

int main(){
  cin>>N;
  G.assign(N,vector<Edge>());
  for(int i=0; i<N-1; ++i){
    int u,v,w;
    cin>>u>>v>>w;
    --u,--v;
    G[u].push_back(Edge(v, w));
    G[v].push_back(Edge(u, w));
  }
  res.assign(N, 0);
  dfs(0,-1,1);
  for(auto v:res) cout<<v<<endl;
  return 0;
}

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


signed main() {
    int N;
    cin >> N;
    int X[110];
    rep (i, N) {
        cin >> X[i];
    }

    ll min = 10000000;
    rep(i, 100) {
        ll sum = 0;
        rep (j, N) {
            ll a = i - X[j];
            if (a < 0) a *= -1;
            sum += (a * a);
        }
        if (sum < min) min = sum;
    }
    cout << min << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
map<int,int> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>x, M[x]++;
	if(M.size()>2) {
		return _P("No\n");
	}
	else if(M.size()==1) {
		x=M.begin()->first;
		
		if(x==N-1) return _P("Yes\n");
		if(x*2<=N) return _P("Yes\n");
		return _P("No\n");
	}
	else {
		auto X=*M.begin();
		auto Y=*M.rbegin();
		map<int,int> A;
		FOR(i,N) {
			if(i<X.second) {
				A[i]=1;
				if(A.size()>X.first) return _P("No\n");
			}
			else {
				x=X.second + (i-X.second)%(Y.first-X.second);
				A[x]++;
			}
		}
		map<int,int> B;
		FORR(r,A) {
			if(r.second==1) B[A.size()-1]++;
			else B[A.size()]+=r.second;
		}
		if(M==B) {
			_P("Yes\n");
		}
		else {
			_P("No\n");
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
unsigned long long r[100006];
void solve(){
    
}
int main() {
    int n;
    unsigned long long t[100006],a[100006];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
        r[i]=-1;
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    r[0]=t[0];
    r[n-1]=a[n-1];
    if(t[0]>a[0]||t[n-1]<a[n-1]){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        if(t[i]>t[i-1]){
            if(t[i]>a[i]){
                cout<<0<<endl;
                return 0;
            }
            r[i]=t[i];
        }
    }
    for(int i=n-2;i>=0;i--){
        if(a[i]>a[i+1]){
            if(t[i]<a[i]){
                cout<<0<<endl;
                return 0;
            }
            r[i]=a[i];
        }
    }
    unsigned long long l=1;
    for(int i=0;i<n;i++){
        if(r[i]==-1)
            l=(l*min(a[i],t[i]))%1000000007;
    }
    cout<<l<<endl;
}

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

int main()
{
    char x;
    scanf("%c",&x);
    if(x=='a'||x=='e'||x=='i'||x=='o'||x=='u')
    {
        printf("vowel");
    }
    else
    {
        printf("consonant");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

ll A[100001];
vector<int> G[100001];

inline ll dfs(int u, int p) {
    if (G[u].size() == 1) return A[u];
    ll ret = 2*A[u], m = 0;
    for (int v : G[u]) if (v != p) {
        ll x = dfs(v, u);
        ret -= x;
        m = max(x, m);
    }
    if (ret < 0 || ret > A[u] || m > A[u]) {
        cout << "NO";
        exit(0);
    }
    return ret;
}

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N; cin >> N;
    for (int u = 1; u <= N; ++u) cin >> A[u];
    for (int i = 1; i < N; ++i) {
        int a, b; cin >> a >> b;
        G[a].push_back(b), G[b].push_back(a);
    }

    if (N == 2) {
        cout << (A[1] == A[2] ? "YES" : "NO");
        return 0;
    }

    int s = 1;
    while (G[s].size() == 1) ++s;
    cout << (dfs(s, 0) ? "NO" : "YES");
    return 0;
}

Measured memory_bytes: 16536
#include <bits/stdc++.h>
using  namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)\
        cin>>arr[i];
    int ans[n] = {0};
    ans[0] = 0;
    ans[1] = abs(arr[1]-arr[0]);
    for(int i=2; i<n; i++)
    {
        ans[i] = min( (ans[i-2]+abs(arr[i]-arr[i-2])),  (ans[i-1]+abs(arr[i]-arr[i-1])) );
    }
    cout<<ans[n-1];
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int N, W, w, v;
vector<int> vec[4];
int cnt;
int ans;
int coun;

signed main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> w >> v;
		if (i == 0)cnt = w;
		vec[w - cnt].push_back(v);
	}
	for (int i = 0; i < 4; i++) {
		sort(all(vec[i]));
		reverse(all(vec[i]));
	}
	for (int i = 0; i <= max((int)0,min(W / (cnt + 3),(int)vec[3].size())); i++) {
		W -= i * (cnt + 3);
		for (int j = 0; j <= max((int)0,min(W / (cnt + 2), (int)vec[2].size())); j++) {
			W -= j * (cnt + 2);
			for (int k = 0; k <= max((int)0,min(W / (cnt + 1),(int)vec[1].size())); k++) {
				W -= k * (cnt + 1);
				for (int l = 0; l <= max((int)0,min(W / cnt, (int)vec[0].size())); l++) {
					coun = 0;
					for (int ii = 0; ii < i; ii++)coun += vec[3][ii];
					for (int jj = 0; jj < j; jj++)coun += vec[2][jj];
					for (int kk = 0; kk < k; kk++)coun += vec[1][kk];
					for (int ll = 0; ll < l; ll++)coun += vec[0][ll];
					ans = max(ans, coun);
				}
				W += k * (cnt + 1);
			}
			W += j * (cnt + 2);
		}
		W += i * (cnt + 3);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
l = list(map(int, input().split()))
q = 0
c = 0
l.sort()
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      n1 = l[i]
      n2 = l[j]
      n3 = l[k]
      c += 1
      if n1 == n2 or n2 == n3 or n3 == n1:
        continue
      if n1 + n2 > n3:
        q += 1
print(q)

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <stack>
#include <cassert>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;

double a[N];
int n, k;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie();
    
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) {
        double x;
        cin >> x;
        a[i] = a[i-1] + (x + 1) / 2.0;
    }
    double ans = 0;
    for(int i = k; i <= n; ++i) {
        ans = max(ans, a[i] - a[i-k]);
    }
    printf("%.6f\n", ans);
}


Measured memory_bytes: 1792
# 素因数分解 O(√N)
def prime_decomposition(n):
    i = 2
    prime2exponent = {}  # key:prime --> value:its exponent
    while i*i <= n:
        while n % i == 0:
            n //= i
            if i in prime2exponent:
                prime2exponent[i] += 1
            else:
                prime2exponent[i] = 1
        i += 1
    if n > 1:
        if n in prime2exponent:
            prime2exponent[n] += 1
        else:
            prime2exponent[n] = 1
    return prime2exponent

N = int(input())
p2e = prime_decomposition(N)


def calc_elem(n):
    res = 1
    while res * (res + 1) // 2 <= n:
        if (res+1)*(res+2)//2 > n:
            break
        else:
            res += 1
    return res

ans = 0
for v in p2e.values():
    ans += calc_elem(v)
print(ans)


Measured memory_bytes: 62908
#include<iostream>
using namespace std;
int main(){
	int m[10],i,j,k,max;
	for(i=0;i<10;i++)cin>>m[i];
	for(i=0;i<3;i++){
		max=i;
		for(j=i;j<10;j++)if(m[j]>m[max])max=j;
		k=m[max];m[max]=m[i];m[i]=k;}
	cout<<m[0]<<endl<<m[1]<<endl<<m[2]<<endl;
	return 0;}


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
int main(){
	using namespace std;
	int i,a,b,c;

	cin>>i;
	while(cin>>a>>b>>c){
		if(a*a==b*b+c*c){
			cout<<"YES"<<endl;
		}
		else if(c*c==b*b+a*a){
			cout<<"YES"<<endl;
		}
		else if(b*b==a*a+c*c){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
}

Measured memory_bytes: 1156
def b_median_pyramid_easy(N, X):
    # 頂点の列とその右の列が常にXになるような数列を構成できればいい
    if X in [1, 2 * N - 1]:
        return 'No'  # この2つは中央値になりえないので、構成不可能
    if N == 2:
        return 'Yes\n1\n2\n3'
        # 下の処理はN>=3のときに行う。N=2, X=2のときは 1 2 3 が解になる

    ans_seq = [k for k in range(1, 2 * N)]
    if X == 2:
        # 1から2*N-1までの数字を昇順に並べ、値がXの周辺の数字を4つ取り出し、
        # 中央に入れる
        tmp = [k for k in range(1, X - 1)] + [k for k in range(X + 3, 2 * N)]
        center = [X + 1, X, X - 1, X + 2]
    else:
        tmp = [k for k in range(1, X - 2)] + [k for k in range(X + 2, 2 * N)]
        center = [X - 1, X, X + 1, X - 2]
    ans_seq = tmp[:N - 2] + center + tmp[N - 2:]
    ans = 'Yes\n' + '\n'.join(map(str, ans_seq))
    return ans

N, X = [int(i) for i in input().split()]
print(b_median_pyramid_easy(N, X))


Measured memory_bytes: 27872
#include <iostream>
#include <vector>
using namespace std;
vector <int> v[100005];
int dp[100005];
int dfs(int node){
	if(dp[node]!=0){
		return dp[node];
	}
	int maxn=0;
	for(auto a:v[node])
		maxn=max(maxn,dfs(a));
	return dp[node]=maxn+1;
}
int main() {
	// your code goes here
	int n,m;
	cin >>n>>m;
	for(int i=1;i<m+1;i++){
		int a,b;
		cin >>a>>b;
		v[a].push_back(b);
	}
	int maxd=0;
	for(int i=1;i<=n;i++){
		if(dp[i]==0){
			dfs(i);
		}
		maxd=max(maxd,dp[i]);
	}
	cout<<maxd-1;
	return 0;
}




Measured memory_bytes: 8192
/* ex4_2
   takafumi_ueki */
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535

int main(void){
    int hour_length,min_length,hour,min;
    double rad,distance;
    scanf("%d %d %d %d",&hour_length,&min_length,&hour,&min);
    //時針と分針の成す角を計算する
    rad = (2*PI*min/60)-(2*PI*(hour*60+min)/720);
    //余弦の定理を用いて端点の間の距離を計算する。
    distance = sqrt((double)(pow(hour_length,2) + pow(min_length,2) - 2*hour_length*min_length*cos(rad)));
    printf("%.9f\n",distance);
    return 0;
}


Measured memory_bytes: 2576
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 1e+9
#define ll long long int

int main(){
    int n; cin >> n;
    vector<ll> a(n+1),b(n+1);
    rep(i,n+1) cin >> a[i];
    
    if(n == 0){
        if(a[0] == 1){cout << 1 << endl; return 0;}
        else {cout << -1 << endl; return 0;}
    }
    if(a[0] != 0) {cout << -1 << endl; return 0;}
        
    

    
    for(int i = n-1; i >= 0; i--){
        b[i] = b[i+1] + a[i+1];
    }

    b[0] = 1; b[n] = a[n];
    for(int i = 1; i < n + 1; i++){
        b[i] = min(b[i], 2 * b[i-1] - a[i]); //cout << b[i] << endl;
        if(b[i] < 0){cout << -1 << endl; return 0;}
    }
    
    if(b[n] < 0){cout << -1 << endl; return 0;}
    
    ll ans = 0;
    rep(i,n+1) ans += a[i];
    rep(i,n) ans += b[i]; //cout << b[i] << endl;}
    cout << ans << endl;
}


Measured memory_bytes: 4848
#  --*-coding:utf-8-*--

MOD = 1000000007

def f(A):
    Q = [0]*3
    X = 1
    
    for a in A:
        Q2 = list(filter(lambda iq: iq[1] == a, enumerate(Q)))

        if len(Q2) == 0:
            return 0
        
        X *= len(Q2)
        X %= MOD
        

        Q[Q2[0][0]] += 1

    return X



def main():
    N = int(input())
    A = list(map(int, input().split()))

    print(f(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
loop do
  # 入力
  m = gets.to_i
  break if m == 0
  seiza_x,seiza_y = [],[]
  m.times {|i| seiza_x[i], seiza_y[i] = gets.split(" ").map(&:to_i)}
  n = gets.to_i
  sky = {}
  n.times {sky[ gets.split(" ").map(&:to_i) ] = true}

  # 星座の最初の星の座標を原点に合わせる
  dx,dy = seiza_x[0] ,seiza_y[0]
  m.times {|i| seiza_x[i] -= dx; seiza_y[i] -= dy}

  # main
  res_x, res_y = nil, nil
  sky.each_key do |star|
    x,y = star[0], star[1]
    m.times do |i|
      break unless sky.has_key?([x+seiza_x[i], y+seiza_y[i]])
      res_x,res_y = x-dx, y-dy if i == m-1
    end
    break unless res_x.nil?
  end

  puts "#{res_x} #{res_y}"
end

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

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string s,t;
  cin >> s >> t;
  vector<vector<int>> dp(s.length()+5, vector<int>(t.length()+5, 0));
  dp[0][0] = 0;
  rep(i, s.length()+1) rep(j, t.length()+1) {
    if (i == 0 || j == 0) dp[i][j] = 0;
    else if (s[i-1] != t[j-1]) {
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
    else dp[i][j] = dp[i-1][j-1] + 1;
  }
  string ans = "";
  int y = s.length(), x = t.length();
  while (x-1 >= 0 && y-1 >= 0) {
    int cur = dp[y][x];
    if (dp[y-1][x] != cur && dp[y][x-1] != cur && dp[y-1][x-1]+1 == cur) {
      ans += s[y-1];
      x--; y--;
    }
    else if (dp[y-1][x] == cur) {
      y--;
    }
    else if (dp[y][x-1] == cur) {
      x--;
    }
  }
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35712
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

void swap_uint8(uint8_t *x, uint8_t *y)
{
    uint8_t tmp = *x ;
    *x          = *y ;
    *y          = tmp;
}

uint16_t selection_sort(uint8_t *a, uint8_t n)
{
    uint16_t n_loop = 0;
    for(uint8_t i=0; i<n; ++i){
        uint8_t minj = i;
        for(uint8_t j=i+1; j<n; ++j)
            if(a[j] < a[minj])
                minj = j;
        if(minj != i){
            swap_uint8(&a[i], &a[minj]);
            ++n_loop                   ;
        }
    }
    return n_loop;
}

int main()
{
    uint8_t n;
    scanf("%"PRIu8, &n);

    uint8_t a[n];
    for(uint8_t i=0; i<n; ++i)
        scanf("%"PRIu8, a + i);

    uint16_t n_loop = selection_sort(a, n);

    printf("%"PRIu8, a[0]);
    for(uint8_t i=1; i<n; ++i)
        printf(" %"PRIu8, a[i]);
    printf("\n%"PRIu16"\n", n_loop);

    return 0;
}

Measured memory_bytes: 1824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var x = m1(n);

        var ans = 0;
        var odd = true;

        for (int i = 0; i < x - 1; i++)
        {
            if (odd)
            {
                ans += 9 * (int)Math.Pow(10, i);
            }
            odd ^= true;
        }

        if (odd) ans += n - (int)Math.Pow(10, x - 1) + 1;

        Console.WriteLine(ans);
    }

    static int m1(int n)
    {
        var ans = 1;
        while (0 < (n /= 10)) ans++;
        return ans;
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }
 
static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;
 
struct data{int h, w; };
 
namespace std
{
  inline bool operator < (const data& a, const data& b)
  {
    return a.h*a.h+a.w*a.w!=b.h*b.h+b.w*b.w ? a.h*a.h+a.w*a.w<b.h*b.h+b.w*b.w : a.h < b.h;
  }
}
 
vector<data> g;
int h, w;
 
int main()
{
  erep(i, 1, 155) erep(j, i+1, 155) g.pb((data){i, j});
  sort(ALL(g));
 
  while(cin >> h >> w, h){
    data res = *upper_bound(ALL(g), (data){h, w});
    cout << res.h << ' ' << res.w << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1344
n = gets.to_i

mae = 0
usr = n/2-1

puts mae
STDOUT.flush
maeJ = gets.chomp
exit if maeJ == 'Vacant'

puts usr
STDOUT.flush
usrJ = gets.chomp
exit if usrJ == 'Vacant'

#itiou
puts n-1
STDOUT.flush
lastJ = gets.chomp
exit if lastJ == 'Vacant'

17.times{
  if ((usr-mae)%2==1) == (maeJ != usrJ)
    #ushiro
    if mae==0
      mae = usr
      usr = n-1
      maeJ = usrJ
      usrJ = lastJ
    end
    tmp = (mae+usr)/2
    puts tmp
    STDOUT.flush
    tmpJ = gets.chomp
    exit if tmpJ == 'Vacant'
    if ((tmp-mae)%2==1) == (maeJ != tmpJ)
      mae = tmp
      maeJ = tmpJ
    else
      usr = tmp
      usrJ = tmpJ
    end
  else
    #mae
    tmp = (mae+usr)/2
    puts tmp
    STDOUT.flush
    tmpJ = gets.chomp
    exit if tmpJ == 'Vacant'
    if ((tmp-mae)%2==1) == (maeJ != tmpJ)
      mae = tmp
      maeJ = tmpJ
    else
      usr = tmp
      usrJ = tmpJ
    end
  end
}
exit

Measured memory_bytes: 2384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] S = new String[n];
		for(int i = 0 ; i < n ; i++) {
			S[i] = sc.next();
		}
		String word = "";
		for(char c = 'a' ; c <= 'z' ; c++) {
			int min = 10000007;
			for(int i = 0 ; i < n ; i++) {
				int cnt = 0;
				for(int j = 0 ; j < S[i].length() ; j++) {
					if(S[i].charAt(j) == c) {
						cnt++;
					}
				}
				min = Math.min(min, cnt);
			}
			for(int i = 0 ; i < min ; i++) {
				word += String.valueOf(c);
			}
		}
		System.out.println(word);
	}
}


Measured memory_bytes: 21716
r,c = map(int,input().split())

last_row =[0 for _ in range(c+1)]

while r > 0:
    n =[int(n) for n in input().split()]
    n.append(sum(n))

    for i in range(len(n)):
        last_row[i] += n[i]

    print(" ".join([str(i) for i in n ]))

    r-=1

print(" ".join([str(i) for i in last_row ]))



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

int main(){
  int n;
  cin>>n;
  int j=0;
  for (int i=0;i<n;i++){
    string s;
    cin>>s;
    if (s=="Y"){
      j++;
      break;
    }
  }
  if (j==0){
    cout<<"Three"<<endl;
  }else{
    cout<<"Four"<<endl;
  }
}

Measured memory_bytes: 256
n,l=gets.split.map &:to_i

eat = []
n.times do |i|
  eat << (l + i)
end

ee = eat[0].abs
num = 0
eat.each_with_index do |e,i|
  if e.abs < ee
    ee = e.abs
    num = i
  end
end

sum = 0
eat.each { |i| sum += i }

puts sum - eat[num]

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int mod = 1e9 + 7;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int>v(n);
	unordered_map<int, int>m;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		m[v[i]]++;
	}
	bool ok = false;
	for (int i = n - 1; i >= 0; i -= 2) {
		if (!(m[i] == 2 || (m[i] == 1 && i == 0)))ok = true;
	}
	if (ok)cout << "0" << endl;
	else {
		ll ans = 1;
		for (int i = 0; i < n / 2; i++) {
			ans *= 2;
			ans = ans % mod;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 7216
while True:
    p=int(input())      #while文のなかで定義
    if p==0:break       #p=pay
    a=0                 #aを定義しておく
    c=1000-p        #c=change
    for i in [500,100,50,10,5,1]:
        a+=c//i     #aにc//iを足す
        c=c%i
    print(a)
    


Measured memory_bytes: 5592
#include<iostream>
 
using namespace std;
 
#define INF 1000000000
 
int ll(int a){return (a<0)?-a:a;}
 
int main(){
 
	int n;
	int x[4],y[4]; /*0,1,2,3 -> a,b,c,d*/
	int abcd[4];
	int dis,min=INF;
 
	cin>>n;
	 
	for(int i=0;i<4;i++) cin>>abcd[i];

	for(int i=n;i>=1;i--){ 
		for(int k=0;k<4;k++){
			x[k]=(abcd[k]-1)%i;
			y[k]=(abcd[k]-1)/i;
		}
		dis=ll(x[0]-x[1])+ll(y[0]-y[1])+ll(x[2]-x[3])+ll(y[2]-y[3]);
		if(dis<min) min=dis;
	}
 
	cout<<min<<endl;
 
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007
 
// // for using in pairs
#define F first
#define S second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T>& v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2>& p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

template<typename T1, typename T2>
istream& operator>>(istream &istream, pair<T1, T2>& p)
{
	istream >> p.first >> p.second;
	return istream;
}

template<typename T>
istream& operator>>(istream &istream, vector<T>& a)
{
	for (auto &it : a)
		istream >> it;
	return istream;
}

// Utility functions.

int GCD(int a, int b)
{
	if (!b)
		return a;
	return GCD(b, a % b);
}

int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}

int modpow(int x, int n, int m = MOD)
{
	if (n == 0) return 1 % m;
	long long u = modpow(x, n / 2, m);
	u = (u * u) % m;
	if (n % 2 == 1)
		u = (u * x) % m;
	return u;	
}

//////////////////// START CODE HERE ///////////////////////////

void solve(int tc)
{
	string s;
	cin >> s;
	if (s.back() == 's')
		cout << s << "es\n";
	else
		cout << s << "s\n";
}	

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

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

	int t = 1;
	// cin >> t;		
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 3660
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 1005;
LL a[N], b[N], c[N];

int main() {
	int x, y, z, k;
	scanf("%d%d%d%d", &x, &y, &z, &k);
	REP(i, x)scanf("%lld", a + i);
	REP(i, y)scanf("%lld", b + i);
	REP(i, z)scanf("%lld", c + i);
	VLL bc(y*z, 0);
	REP(i, y) {
		REP(j, z) {
			bc[i*z + j] = b[i] + c[j];
		}
	}
	sort(ALL(bc), greater<LL>());
	sort(a, a + x, greater<LL>());
	priority_queue<LL, vector<LL>, greater<LL>> q;

	REP(i, x) {
		REP(j, y*z) {
			if (q.size() < k)q.push(a[i] + bc[j]);
			else {
				if (q.top() >= a[i] + bc[j])break;
				q.pop();
				q.push(a[i] + bc[j]);
			}
		}
	}
	VLL ret(k);
	REP(i, k) {
		ret[k-i-1] = q.top();
		q.pop();
	}
	REP(i, k)printf("%lld\n", ret[i]);
	return 0;
}

Measured memory_bytes: 8192
N,K=map(int,input().split())
AB=[]
for i in range(N):
  a,b=map(int,input().split())
  AB.append([a,b])
AB=sorted(AB,key=lambda x:x[0])

for i in range(N):
  if AB[i][1]<K:
    K-=AB[i][1]
  else:
    print(AB[i][0])
    break

Measured memory_bytes: 22144
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int digitsum = 0;
   int tmp = N;
   for(int i = 0;i<10;i++)
   {
     digitsum += tmp%10;
     tmp -= tmp%10;
     tmp = tmp/10;
   }
   
   if(N%digitsum==0) System.out.println("Yes");
   else System.out.println("No");
 }
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }

int main(){
	int n ; 
	cin >> n ; 
	string s;
	multiset<string> m ; 
	vector<string> words; 
	for(int i = 0 ; i < n ; i++ ){
		cin >> s ; 
		sort(all(s));
		words.pb(s);  
		m.insert(s); 
	}
	ll ans = 0 ; 
	for(string w : words){
		ll c= m.count(w); 
		if( c ){ 
			m.erase(w); 
		}if(c>1)
			ans += (c*(c-1))/2 ;
	}cout << ans << endl ; 
}

Measured memory_bytes: 15092
# include <stdio.h>

int count_rainy(char* weather);

int main(){
  char weather[4];
  int count_num = 0;
  scanf("%s", weather);
  count_num = count_rainy(weather);
  printf("%d\n", count_num);
  return 0;
}

int count_rainy(char* weather){
  int count_num = 0;
  for (int i=0; i<3; i++){
    if (weather[i] != 'a' && weather[i] !='b'){
      if (weather[i] == 'S') weather[i] = 'a';
      else {
        weather[i] = 'b';
        count_num = 1 + count_rainy(weather);
        if (count_num == 2) if (weather[1] == 'a') count_num = 1;
      }
    }
  }
  return count_num;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using st = string;
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }

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

#define INFTY 1e9

int main() {
    ll h, w;
    cin >> h >> w;
    ll ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;
    vector<st> s(h);
    rep(i, h) cin >> s.at(i);
    vector<vector<int>> dist(h, vector<int>(w, INFTY));
    deque<Pll> q;
    dist.at(ch).at(cw) = 0;
    q.emplace_back(ch, cw);
    while(!q.empty()){
        int i = q.front().first; // y座標
        int j = q.front().second; // x座標
        q.pop_front(); // 取り出し
        int d = dist.at(i).at(j);
        rep(k, 4){ // 魔法を使わない遷移
            int ni = i + dy[k];
            int nj = j + dx[k];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue; // 枠外は操作しない
            if(s.at(ni).at(nj) == '#') continue; // 壁は操作できない
            if(dist.at(ni).at(nj) <= d) continue; // 距離が更新できない遷移はしない
            dist.at(ni).at(nj) = d;
            q.emplace_front(ni, nj);
        }
        for(int my = -2; my <= 2; my++){ // 魔法を使う遷移
            for(int mx = -2; mx <= 2; mx++){
                int ni = i + my;
                int nj = j + mx;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue; // 枠外は操作しない
                if(s.at(ni).at(nj) == '#') continue; // 壁は操作できない
                // 魔法を使うごとにコストが1ずつ増えるためd+1とする
                if(dist.at(ni).at(nj) <= d + 1) continue; // 距離が更新できない遷移はしない
                dist.at(ni).at(nj) = d + 1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist.at(dh).at(dw);
    if(ans == INFTY) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      A[--a]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] == 0) ans++;
  }

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
 
ll n,m,ans=0;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
void work(int x){
	if(n%x==0)ans++;
	while(n%x==0)n/=x;
}
int main(){
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n>>m;
	n=__gcd(n,m);
	repeat(i,2,int(sqrt(n)+2))work(i);
	if(n!=1)ans++;
	cout<<(ans+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
a,b,c,d = input().split(" ")
a = int(a)
b = int(b)
c = int(c)
d = int(d)
t1 = 30*c + 0.5*d
t2 = 6*d
e = math.cos(math.radians(t1-t2))
f = a*a + b*b - 2*a*b*e
print(f ** 0.5)

Measured memory_bytes: 9576
[h,w] = [int(i) for i in input().split()]
a = []
t = 0
for i in range(h):
    tmp = input()
    if tmp != "." * w:
        a.append(tmp)
    else:
        t += 1
h -= t
ls = []
ans = []
for i in range(w):
    ls.append(i)
for i in range(w):
    intmp = 1
    for j in range(h):
        if a[j][i] == "#":
            intmp *= 0
    if intmp == 1:
        ls.pop(ls.index(i))
for i in range(h):
    tmp = ""
    for j in range(w):
        if j in ls:
            tmp += a[i][j]
    ans.append(tmp)

for i in range(h):
    print(ans[i])


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

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

void solve() {
  // main coding
  ll a,b,c; cin>>a>>b>>c;
  cout<<min(c,b/a)<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
// cout<<fixed<<setprecision(10);
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
 
int main() {
    int a, b, c; cin >> a >> b >> c;
    if(a != b && b != c && a != c) {
        cout << "No" << endl;
        return 0;
    }
    if(a==b && b==c) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var stop = new int[8, 8] {{1,4,1,4,1,2,1,2},{4,1,4,1,2,1,2,1} ,
                                             {1,4,1,2,1,2,1,4},{4,1,2,1,2,1,4,1},
                                             {1,2,1,2,1,4,1,4},{2,1,2,1,4,1,4,1} ,
                                             {1,2,1,4,1,4,1,2},{2,1,4,1,4,1,2,1 }};

        var after = new int[8];
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var jenny = Array.ConvertAll(line.Trim().Split(' '), int.Parse);
            for (int i = 0; i < 8; i++)
            {
                var stotal = 0;
                for (int j = 0; j < 8; j++)
                    stotal += Math.Max(jenny[j] - stop[i, j], 0);
                after[i] = stotal;
            }
            var minclist = new Dictionary<int, int>();
            for (int i = 0; i < 8; i++)
                if (after[i] == after.Min()) minclist[i] = StoptoNum(stop, i);
            var resno = minclist.OrderBy(x => x.Value).First();
            for (int i = 0; i < 8; i++)
            {
                Console.Write(stop[resno.Key, i]);
                if (i == 7) Console.WriteLine();
                else Console.Write(" ");
            }
        }
    }
    public static int StoptoNum(int[,] s, int a)
    {
        var moji = "";
        for (int i = 0; i < 8; i++)
            moji += s[a, i].ToString();
        return int.Parse(moji);
    }

}

Measured memory_bytes: 10188
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Treasure Hunt
// 2012/09/19
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, m;
	int[] xs, ys;

	void run(){
		n=sc.nextInt();
		m=sc.nextInt();
		xs=new int[n];
		ys=new int[n];
		for(int i=0; i<n; i++){
			xs[i]=sc.nextInt();
			ys[i]=sc.nextInt();
		}
		solve();
	}

	void solve(){
		TreeSet<Integer> xSet=new TreeSet<Integer>();
		TreeSet<Integer> ySet=new TreeSet<Integer>();

		for(int i=0; i<n; i++){
			xSet.add(xs[i]);
			ySet.add(ys[i]);
		}
		xSet.add((int)1e9);
		ySet.add((int)1e9);
		xSet.add((int)-1e9);
		ySet.add((int)-1e9);

		Integer[] xss=xSet.toArray(new Integer[0]);
		Integer[] yss=ySet.toArray(new Integer[0]);
		
		int w=xss.length;
		int h=yss.length;

		int[][] a=new int[h+1][w+1];
		for(int i=0; i<n; i++){
			int x=binarySearch(xss, xs[i]);
			int y=binarySearch(yss, ys[i]);
			a[y+1][x+1]++;
		}

		for(int j=0; j<h; j++){
			for(int i=0; i<w; i++){
				a[j+1][i+1]+=a[j+1][i]+a[j][i+1]-a[j][i];
			}
		}

		StringBuilder sb=new StringBuilder();
		for(int i=0; i<m; i++){
			int x1=binarySearch(xss, xSet.ceiling(sc.nextInt()));
			int y1=binarySearch(yss, ySet.ceiling(sc.nextInt()));
			int x2=binarySearch(xss, xSet.floor(sc.nextInt()))+1;
			int y2=binarySearch(yss, ySet.floor(sc.nextInt()))+1;
			sb.append(a[y2][x2]-a[y1][x2]-a[y2][x1]+a[y1][x1]);
			sb.append('\n');
		}
		print(sb.toString());
	}

	class Scanner{
		BufferedReader br;
		StringTokenizer st;

		Scanner(InputStream in){
			br=new BufferedReader(new InputStreamReader(in));
			eat("");
		}

		void eat(String s){
			st=new StringTokenizer(s);
		}

		String nextLine(){
			try{
				return br.readLine();
			}catch(IOException e){
				throw new IOError(e);
			}
		}

		boolean hasNext(){
			while(!st.hasMoreTokens()){
				String s=nextLine();
				if(s==null)
					return false;
				eat(s);
			}
			return true;
		}

		String next(){
			hasNext();
			return st.nextToken();
		}

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

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 134000