akhauriyash/Code-Regression huggingface dataset:
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int A,B,H,M;
    cin >> A>>B>>H>>M;
    double pi = 3.141592653589793;
    double d_H = 30 * H + 0.5 * M;
    double d_M = 6 * M;
    //cout << d_H << " " << d_M << endl;
    double ans;
    if(d_H >= d_M) {
        if(d_H-d_M >= 180) ans = sqrt(A*A+B*B-2*A*B*cos((360-(d_H-d_M))*pi/180));
        else ans = sqrt(A*A+B*B-2*A*B*cos((d_H-d_M)*pi/180));
    } else if(d_M-d_H >= 180) ans = sqrt(A*A+B*B-2*A*B*cos((360-(d_M-d_H))*pi/180));
           else ans = sqrt(A*A+B*B-2*A*B*cos((d_M-d_H)*pi/180));

    printf("%.20f\n",ans);
}

Measured memory_bytes: 4188
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		// 計算
		String result = "No";
		if(x == y){
		    System.out.println("Yes");
		    return;
		}
		if(x == 4 || x == 6 || x == 9 || x == 11){
		    if(y == 4 || y == 6 || y == 9 || y == 11) result = "Yes";
		}else{
		    if(!(y == 4 || y == 6 || y == 9 || y == 11 || y == 2)) result = "Yes";
		}
		
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;

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

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

int main(){
    ios::sync_with_stdio(false);
	int n,m,ans=0;
	map<string,int> mp;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(mp.find(s)==mp.end()){
			mp[s]=1;
		}else{
			mp[s]++;
		}
	}
	cin>>m;
	for(int i=0;i<m;i++){
		string s;
		cin>>s;
		if(mp.find(s)==mp.end()){
			mp[s]=-1;
		}else{
			mp[s]--;
		}
	}
	for(auto ite=mp.begin();ite!=mp.end();ite++){
		ans=max(ans,ite->second);
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
LL a,b,n,x;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	x=min(n,b-1);
	printf("%lld\n",(a*x)/b);
}


Measured memory_bytes: 3776
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
const double PI=3.14159265358979323846;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	double a,b,x;
	cin>>a>>b>>x;
	double v = a*a*b;
	double s;
	if(2*x < v){
		s=a*b*b;
		s/=x;
		s/=2;
	}
	else{
		s=(v-x);
		s*=2;
		s/=a;
		s/=a;
		s/=a;
	}
	double t = atan(s)*180.0;
	t/=PI;
	cout<<fixed<<setprecision(10)<<t;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};
vvl G;
ll dfs(int v){
  ll res=1;
  for(auto nv:G[v]){
    res+=dfs(nv);
  }
  return res;
}
    
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n,a,b,c,d,e;
  cin >> n>>  a >> b >> c >> d >> e;
  
  ll m=min({a,b,c,d,e});
  cout << (n+m-1)/m+4 << endl;
}


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

using namespace std;

int main()
{
    int n,i,cnt=0;
    cin >> n;

    vector<int> p(n);
    for(i=0; i<n; i++)
        cin >> p.at(i);

    for(i=1; i<n-1; i++){
        if(p.at(i) > p.at(i-1) && p.at(i) < p.at(i+1))
            cnt++;
        else if(p.at(i) < p.at(i-1) && p.at(i) > p.at(i+1))
            cnt++;
        
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char ch;
	cin>>ch;
	if(ch>='a'&&ch<='z')
		cout<<'a'<<"\n";
	else
		cout<<'A'<<"\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define For(aa,bb,cc) for(int aa=(bb);aa<=(int)(cc);++aa)
#define Forr(aa,bb,cc) for(int aa=(bb);aa>=(int)(cc);--aa)
using namespace std;
typedef long long LL;
const int maxn=1e6+10;
int n;
int stone[maxn];
int be[maxn],ne[maxn<<1],to[maxn<<1],e; int ans[maxn]; bool vis[maxn];

template<class T>inline void read(T &x){
	x=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
}

inline void add_edge(int x,int y){
	to[++e]=y,ne[e]=be[x],be[x]=e;
	to[++e]=x,ne[e]=be[y],be[y]=e;
}

int dfs(int node){
	ans[node]=0;vis[node]=1;
	for(int i=be[node];i;i=ne[i]){
		int u=to[i];
		if(stone[u]>=stone[node]) continue;
		ans[node]|=!dfs(u);
	}
	return ans[node];
}

int main(){
	int x,y;
	read(n);
	For(i,1,n) read(stone[i]);
	For(i,1,n-1) read(x),read(y),add_edge(x,y);
	For(i,1,n) if(!vis[i]) dfs(i);
	For(i,1,n){
		if(ans[i]){
			printf("%d ",i);
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 8448
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#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 reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<string> s(n);
    vector<vector<int>> cnt(n, vector<int>(26));
    map<vector<int>, ll> mp;
    rep(i, n){
        cin >> s[i];
    }
    rep(i, n){
        for(auto &x : s[i]){
            ++cnt[i][(int)(x - 'a')];
        }
        ++mp[cnt[i]];
    }

    ll ans = 0;
    for(auto it = mp.begin(), end = mp.end(); it != end; ++it){
        ans += it->se * (it->se - 1) / 2;
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 44564
#include<stdio.h>

int main(void)
{
	int pasta[3], juice[2];
	int i,p_min,j_min=0;
	scanf("%d",&pasta[0]);
	scanf("%d", &pasta[1]);
	scanf("%d", &pasta[2]);
	scanf("%d", &juice[0]);
	scanf("%d", &juice[1]);

	p_min = pasta[0];
	for (i = 1; i < 3; i++) 
		if (p_min > pasta[i])p_min = pasta[i];
	
	if (juice[0] > juice[1]) j_min = juice[1];
	else j_min = juice[0];

	printf("%d\n",p_min+j_min-50);
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin>>n;
    unordered_map<int,int> m;
    int f=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        m[x]++;
        if(m[x]==2){
            f=1;
            
        }
    }
    if(f==1){
        cout<<"NO";
    }else{
        cout<<"YES";
    }
}

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

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,c;cin>>a>>b>>c;
  ll k=a;
  bool isok=false;
  rep(i,b) {
    if(k%b==c) {
      isok=true;
      break;
    }
    else k+=a;
  }
  if(isok) puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
		int i=0,n=0,x=0,y=0,j=0,z=0,count=0;
      	cin >> n;
      	int arr[1000002];
      	memset(arr,0,sizeof(arr));
      	for(i=0;i<n;i++){
        	cin >> z;
          	arr[z]++;
        }
      	for(i=1;i<1000001;i++){
        	if(arr[i]!=0){
            	for(j=2*i;j<1000001;j=j+i){
                	arr[j]=0;
                }
            }
        }
      	for(i=1;i<1000001;i++){
        	if(arr[i]==1){count++;}
        }
      cout << count << endl;
}

Measured memory_bytes: 7540
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

constexpr unsigned Mod = 1000000007;

constexpr unsigned Add(unsigned a, unsigned b) { return (a + b) % Mod; }

int main() {
  int N;
  scanf("%d", &N);
  static char S[3000];
  scanf("%s", S);
  static unsigned F[3000];
  fill(F, F + N, 1);
  for (auto i = 1; i < N; ++i) {
    if (S[i - 1] == '<')
      for (auto j = 1; j < N - i; ++j)
        F[j] = Add(F[j - 1], F[j]);
    else {
      auto f = exchange(F[N - i - 1], F[N - i]);
      for (auto j = N - i - 2; j >= 0; --j)
        f = exchange(F[j], Add(f, F[j + 1]));
    }
  }
  printf("%u\n", F[0]);
  return 0;
}


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

#define MOD (1000000000+7)
#define MAX 100

int N;

int main() {
	cin >> N;

	vector< vector<vector<vector<long long>>>>
		dp( N + 1, vector<vector<vector<long long>>>( 4, vector<vector<long long>>( 4, vector<long long>( 4, 0 ) ) ) );
	dp[0][3][3][3] = 1;
	for( int len = 0; len < N; len++ ) {
		for( int c1 = 0; c1 < 4; c1++ ) {
			for( int c2 = 0; c2 < 4; c2++ ) {
				for( int c3 = 0; c3 < 4; c3++ ) {
					if( dp[len][c1][c2][c3] == 0 ) {
						continue;
					}
					for( int a = 0; a < 4; a++ ) {
						if( a == 2 && c1 == 1 && c2 == 0 ||
							a == 1 && c1 == 2 && c2 == 0 ||
							a == 2 && c1 == 0 && c2 == 1 ||
							a == 2 && c1 == 1 && c3 == 0 ||
							a == 2 && c2 == 1 && c3 == 0 ) {
							continue;
						}
						dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
						dp[len + 1][a][c1][c2] %= MOD;
					}
				}
			}
		}
	}
	long long ans = 0;
	for( int c1 = 0; c1 < 4; c1++ ) {
		for( int c2 = 0; c2 < 4; c2++ ) {
			for( int c3 = 0; c3 < 4; c3++ ) {
				ans += dp[N][c1][c2][c3];
				ans %= MOD;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
//abc139_b.cpp
//Sun Sep  1 20:53:25 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 0;
	int inlet = 1;
	while (inlet<b){
		inlet = inlet + a-1;
		ans++;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	long long n, m, d;
	cin >> n >> m >> d;
	double ans = 1.0;
	ans *= m - 1;
	if(d > 0) ans *= 2.0;
	ans *= n - d;
	ans /= n;
	ans /= n;
	cout << setprecision(10) << ans << endl;
	system("pause");
	return 0;
}

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

// ---- ----

int main() {
	IN(int, Q);
	
	auto diff = [](auto a, auto b) { return abs(a - b); };
	
	auto to_str = [](LL v) {
		string s;
		inc(i, 30) {
			s.PB('0' + v % 3);
			v /= 3;
		}
		reverse(ALL(s));
		return s;
	};
	
	vector<LL> ex(30);
	inc(i, 30) { ex[i] = (i == 0 ? 1 : ex[i - 1] * 3); }
	
	inc(q, Q) {
		IN(LL, xs, ys, xg, yg);
		xs--; ys--; xg--; yg--;
		if_not(xs <= xg) { swap(xs, xg); }
		if_not(ys <= yg) { swap(ys, yg); }
		if_not(diff(xs, xg) <= diff(ys, yg)) { swap(xs, ys); swap(xg, yg); }
		
		auto str_xs = to_str(xs);
		auto str_xg = to_str(xg);
		LL ans = diff(xs, xg) + diff(ys, yg);
		inc(i, 30) {
			if(str_xs[i] != str_xg[i]) { break; }
			if(str_xs[i] != '1') { continue; }
			
			LL L = (30 - i) - 1;
			
			LL ya = (ys / ex[L]);
			assert(ya % 3 != 1);
			ya += (ya % 3 == 0 ? 1 : 2);
			ya *= ex[L];
			
			LL xa = (xs / ex[L]) * ex[L];
			LL xb = xa + ex[L];
			xa--;
			
			if_not(ya < yg) { continue; }
			assert(ys < ya && ya + ex[L] - 1 < yg);
			ans += 2 * min(diff(xs, xa), diff(xg, xb));
			break;
		}
		OUT(ans);
	}
}


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

int main() {
  int n, a, b;
  cin>>n>>a>>b;
  int h[n];
  for (int i=0; i<n; i++) cin>>h[i];
  sort(h, h + n);

  int begin = 1;
  int end = (h[n-1] - 1) / b + 1;
  set<int> ans;
  while (begin <= end) {
    int k = begin + (end - begin) / 2;
    long long cnt = 0;
    bool ok = true;
    for (int i=0; i<n; i++) {
      if (h[i] - b * k <= 0) {
        continue;
      }
      cnt += (h[i] - b * k - 1) / (a - b) + 1;
      if (cnt > k) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans.insert(k);
      end = k - 1;
    } else {
      begin = k + 1;
    }
  }
  cout<<*ans.begin()<<endl;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> card(N);
  
  for(int i=0; i<N; i++)
    cin >> card.at(i);
  
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  int A, B;
  A = 0;
  B = 0;
  
  if (N % 2 == 0){
    for(int i=0; i<N; i+=2){
        
      A += card.at(i);
      B += card.at(i+1);
    
    }
  }
  
  if (N % 2 == 1){
    for(int i=0; i<N-1; i+=2){
        
      A += card.at(i);
      B += card.at(i+1);
    
    }
    
    A += card.at(N-1);
    
  }
  
  cout << A - B << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


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

// swap(a,b);
// abs(a,b); a,bの型は問わない
// reverse(a+I,a+r); aは配列,a[i]からa[r-1]までを逆順にする.計算量はN. reverse(str.begin(),str.end());
// sortも上とあまり変わらない.
// ただし,sort(a,a+N,greater<int>());で大きい順にならべかえる.
// stack<int> a; 宣言 上に積み上げたものをとったり、一番上に積み上げる.
// a.push(x); aに要素xをつむ a.pop(); a.size(); a.empty(); これはtrue or false
// a.top;で一番上の要素を返す
// queue<int> a; a.front();
// priority_queue<int,vector<int>,greater<int>> Q1; 最も小さい奴を取り出す
// priority_queue<double,vector<double>,less<double>> Q2;最も大きい値を取り出す
// Q1.top();ができる
// count(a+l,a+r,x);
// find(a+l,a+r,x);
// 文字変換
//char a='a';
//a=a+1;
//cout<<a<<endl;


int main(){
  ll H;cin>>H;
  int ans=0;
  ll tmp=H;
  while(H!=1){
    H=H/2;
    ans++;
  }
  cout<<(long long)pow(2,ans+1)-1<<endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int d, n, m;
int a[MAX_N + 2];

int main(){
	for(;;){
		scanf("%d", &d);
		if(d == 0) break;
		scanf("%d", &n);
		scanf("%d", &m);
		for(int i = 1; i < n; i++) scanf("%d", &a[i]);
		a[0] = 0; a[n] = d;
		sort(a, a + n + 2);
		ll res = 0;
		for(int i = 0; i < m; i++){
			int b;
			scanf("%d", &b);
			res += (ll)min(*(upper_bound(a, a + n + 1, b)) - b, b - *(upper_bound(a, a + n + 1, b) - 1));
		}
		printf("%lld\n", res);
	}
	return 0;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

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

int main() {
    int n, a, max  = 0, max2 = 0, p;
    cin >> n;
    vector<int>as(n);
    for (int i = 1; i <= n; i++){
        cin >> a;
        if (a > max){
            max = a;
            p = i;
        }else if(a > max2){
            max2 = a; 
        }
    }
    for (int i = 1; i <= n; i++){
        if (i == p){
            cout << max2 << endl;
        }else{
            cout << max << endl;
        }
    }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  rep(i,s.size()){
    cout<<s[i];
    if(i==3) cout<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;



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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1LL;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

ll mod_inv(ll x, ll mod) {
	return mod_pow(x, mod - 2, mod);
}

//最大公約数
ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m % n);
}//gcd

//最小公倍数
ll lcm(ll m, ll n) {
	return (m * mod_inv(gcd(m, n), MOD) % MOD * n) % MOD;
}

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

ll pow2_m(ll x, ll n, ll mod) { //x^n 計算量O(logn)
	ll ans = 1ll;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % mod;
		}
		x = x * x % mod; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

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

	ll n;
	cin >> n;
	Array a(n, 0);
	REP(i, n) cin >> a[i];

	map<ll, ll> m;
	vector<map<ll, ll>>	m1(n);
	REP(i, n) {
		factoring(a[i], m1[i]);
		for (auto j : m1[i]) {
			chmax(m[j.first], j.second);//lcmは最大値を取る
		}
	}

	ll d = 1;
	for (auto i : m) {
		(d *= pow2_m(i.first, i.second, MOD)) %= MOD;
	}

	ll ans = 0;
	REP(i, n) {
		(ans += (d * mod_inv(a[i], MOD)) % MOD) %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3968
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        char a=s.charAt(0);
        if(a=='A')out.println("T");
        if(a=='T')out.println("A");
        if(a=='G')out.println("C");
        if(a=='C')out.println("G");
    }
}

Measured memory_bytes: 19796
#include<iostream>
#include<string>

int main() {
  std::string str;
  std::cin >> str;
  int sum = 700;
  for (int i=0; i<str.size(); i++) {
    if (str.at(i) == 'o') {
      sum += 100;
    }
  }
  std::cout << sum << std::endl;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

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

Measured memory_bytes: 764
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias A = Tuple!(long, "i", long, "j");

void main()
{
    auto hwd = readln.split.to!(int[]);
    auto H = hwd[0];
    auto W = hwd[1];
    auto D = hwd[2];
    auto AS = new A[](H*W+1);
    foreach (long i; 0..H) {
        foreach (j, a; readln.split.to!(int[])) {
            AS[a] = A(i, j.to!long);
        }
    }
    auto BS = new long[](H*W+1);
    foreach (x; 1..D+1) {
        while (x+D <= H*W) {
            auto p = AS[x];
            auto q = AS[x+D];
            BS[x+D] = BS[x] + abs(p.i - q.i) + abs(p.j - q.j);
            x += D;
        }
    }
    auto Q = readln.chomp.to!int;
    foreach (_; 0..Q) {
        auto lr = readln.split.to!(int[]);
        writeln(BS[lr[1]] - BS[lr[0]]);
    }
}

Measured memory_bytes: 6012
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
ll MAX=9223372036854775807;
using namespace std;
int main()
{   IOS;
    ll n;
    cin >> n;
        cout << pow(n,2);
    return 0;
}


Measured memory_bytes: 256
//あり本 p135

#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    vector<ll> s;
    ll n ,in, sum = 0;
    cin >> n;
    s.push_back(0);
    REP(i, n){
        cin >> in;
        sum += in;
        s.push_back(sum);
    }
    ll l, r, LL, lr, rl, rr, ms, mb, ans = mod;
    int wl = 0, wr = 2;
    rep(i, 2, n - 1){
        l = s[i];
        r = s[n] - l;
        LL = s[wl];
        lr = l - LL;
        rl = s[wr] - s[i];
        rr = r - rl;
        while(wl < i - 1){
            ll tmp = s[wl + 1] - s[wl];
            if(abs(lr - LL) > abs(lr - tmp - (LL + tmp))){
                lr -= tmp;
                LL += tmp;
                wl++;
            }else break;
        }
        while(wr < n - 1){
            ll tmp = s[wr + 1] - s[wr];
            if(abs(rr - rl) > abs(rr - tmp - (rl + tmp))){
                rr -= tmp;
                rl += tmp;
                wr++;
            }else break;
        }
        ms = min(rl, min(rr, min(LL, lr)));
        mb = max(rl, max(rr, max(LL, lr)));
        ans = min(ans, mb - ms);
        debug;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {
    }
    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    map<int, vector<ll>> mp;
    rep(i, n) mp[uf.root(i)].push_back(a[i]);
    if (sz(mp) == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    vector<ll> nokori;
    for (auto p : mp) {
        sort(all(p.second));
        ans += p.second[0];
        rep(i, sz(p.second) - 1) nokori.push_back(p.second[i + 1]);
    }

    sort(all(nokori));
    if (sz(nokori) < sz(mp) - 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    rep(i, sz(mp) - 2) ans += nokori[i];
    cout << ans << endl;
}

Measured memory_bytes: 12416
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>


#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define int long long

using namespace std;
using namespace std::chrono;


signed main(){
  
  int n;
  cin >> n;
  cout << (int)ceil( 1. * n / 2);
}


Measured memory_bytes: 256
def part(a, q, r)
  x = a[r][1]
  i = q - 1
  for j in 0...r - q
    if a[q + j][1] <= x
      i += 1
      a[i], a[q + j] = a[q + j], a[i]
    end
  end
  a[i + 1], a[r] = a[r], a[i + 1]
  return i + 1
end
def qsort(a, q = nil, r = nil)
  q, r = 0, a.length - 1 if !q
  if q < r
    x = part(a, q, r)
    qsort(a, q, x - 1)
    qsort(a, x + 1, r)
  end
end
cards = []
gets.to_i.times do
  cards << gets.split(" ")
  cards.last[1] = cards.last[1].to_i
end
#cards = [["H", 3], ["S", 3], ["D", 3], ["C", 3], ["H", 1], ["S", 1], ["D", 1], ["H", 2], ["C", 1], ["S", 2], ["D", 2], ["C", 2]]
cards2 = cards.dup
qsort(cards)
i = 0
cards2.sort_by!{|item|
  i += 1
  [item[1], i]
  }
#p cards2
bool = true
cards.each_with_index{|item,idx|
  bool &&= item == cards2[idx]
  }
if bool
  puts "Stable"
else
  puts "Not stable"
end
cards.each{|item|puts item.join(" ")}

Measured memory_bytes: 96644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    int b[n-1];

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int ans;
    int p = a[n-1];
    if(n > 2){
        auto position = lower_bound(a,a+n,a[n-1]/2);
        int l = position - a;

        int s = a[l-1];
        int b = a[l];

        s *= 2;
        b *= 2;
        if(abs(s-p) > abs(b-p)){
            cout << p << ' ' << b/2 << endl;
        }else{
            cout << p << ' ' << s/2 << endl;
        }

    }else{
        cout << a[n-1] << ' ' << a[0] << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
int32_t main(){
	boost;
	int n;
	cin>>n;
	n%=10;
	if(n == 3)
		cout<<"bon"<<endl;
	else if(n == 0 or n==1 or n==6 or n==8)
		cout<<"pon"<<endl;
	else
		cout<<"hon"<<endl;
}

 

Measured memory_bytes: 3624
#include <cstdio>

int main(){
	int n, a[10001];
	a[1] = 2;
	for(int i=2;i<=10000;i++){
		a[i] = a[i-1] + i;
	}

	while(~scanf("%d", &n)){
		printf("%d\n", a[n]);
	}
	return 0;
}

Measured memory_bytes: 0
//同じ連結成分を違う色で塗る工程は、bfsでできるが、実装は
//連結成分を列挙し終えてから新しい色を塗ったほうが、連結成分を列挙中に新しい色を塗っていくよりも断然楽。
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;

class Input {
public:
	int h, w, aimColor;
	int colors[64];	//color[i*w + j] = i行j列の色
	
	bool input(FILE *fp) {
		fscanf(fp, "%d%d%d", &h, &w, &aimColor);
		if (h == 0) {
			return false;
		}
		
		for (int i = 0; i < h*w; i++) {
			fscanf(fp, "%d", colors + i);
		}
		return true;
	}
};

//とにかくそのまま使いたい継承
class Solver : public Input {
public:
	int ans;
	
	int getScore() {
		int ret = bfs(colors[0], colors);
		return ret;
	}
	void dfs(int dep) {
		if (dep == 5) {
			if (colors[0] != aimColor) {
				return;
			}
			int res = getScore();
			ans = max(res, ans);
			return;
		}
		
		for (int i = 1; i <= 6; i++) {
			int copy[64];
			for (int j = 0; j < h*w; j++) {
				copy[j] = colors[j];
			}
			
			bfs(i, colors);
			dfs(dep+1);
			
			for (int j = 0; j < h*w; j++) {
				colors[j] = copy[j];
			}
		}
	}
	
	//戻り値は左上マスを含む連結成分の大きさ
	int bfs(int color, int *dst) {		
		queue<int> que;
		bool done[64] = {false};
		
		//dst[0]と同じ連結成分を抽出
		que.push(0);
		while(!que.empty() ) {
			int v = que.front();
			que.pop();
			if (done[v])
				continue;
			done[v] = true;
			
			int dy[4] = {-1, 0, 1, 0};
			int dx[4] = {0, 1, 0, -1};
			for (int i = 0; i < 4; i++) {
				int y = dy[i] + (v/w);
				int x = dx[i] + (v%w);
				if (0 <= y && y < h && 0 <= x && x < w && dst[y*w + x] == dst[0] && !done[y*w + x]) {
					que.push(y*w + x);
				}
			}
		}
		//その連結成分の全マスをcolorにする
		int ret = 0;
		for (int i = 0; i < h*w; i++) {
			if (done[i]) {
				dst[i] = color;
				ret++;
			}
		}
		return ret;
	}
	
	int solve() {
		ans = 0;
		dfs(0);
		return ans;
	}
}solver;

signed main() {
	while (solver.input(stdin) ) {
		int res = solver.solve();
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>

int main() {
	int m,f,r;
	while(1) {
		scanf("%d %d %d", &m, &f, &r);
		if(m < 0 && f < 0 && r < 0) break;
		if(m < 0 || f < 0) {
			printf("F\n");
		}else if(m+f >= 80) {
			printf("A\n");
		}else if(m+f >= 65) {
			printf("B\n");
		}else if(m+f >= 50) {
			printf("C\n");
		}else if(m+f >= 30) {
			if(r >= 50) {
				printf("C\n");
			}else{
				printf("D\n");
			}
		}else{
			printf("F\n");
		}
	}

	return 0;
}

Measured memory_bytes: 584
# -*- coding: utf-8 -*-   
W, H, x, y, r = map(int, input().split())
x1 = x + r
x2 = x - r
y1 = y + r
y2 = y - r
if x1 <= W and x2 >= 0 and y1 <= H and y2 >= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5600
import itertools
import math
N,M = (int(T) for T in input().split())
List = [[] for TM in range(0,M)]
for TM in range(0,M):
    List[TM] = [int(T) for T in input().split()]
    
Node = [[] for TN in range(0,N+1)]
for TM in range(0,M):
    Node[List[TM][0]].append(List[TM][1])
    Node[List[TM][1]].append(List[TM][0])
    
Count = math.factorial(N-1)
for TI in itertools.permutations(range(2,N+1)):
    Root = (1,)+TI
    for TR in range(0,N-1):
        if Root[TR+1] not in Node[Root[TR]]:
            Count -= 1
            break
print(Count)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n;
	cin >> n;
	vecll a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	ll sum = 0;
	rep(i, n - 1)
		sum += a[i + 1] - a[i];
	cout << sum << endl;
	return 0;
}

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

int main(){
  int x, y;
  cin >> x >> y;
  
  int result = 0;
  if(x > 3 && y > 3){
    cout << 0 << endl;
    return 0;
  }
  else{
    if(x == 3) result += 100000;
    else if(x == 2) result += 200000;
    else if(x == 1) result += 300000;
    else {}
    
    if(y == 3) result += 100000;
    else if(y == 2) result += 200000;
    else if(y == 1) result += 300000;
    else {}
    
    if(x == 1 && y == 1) result += 400000;
    
    cout << result << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<double,double> pii;
typedef pair<pii,int> tpi;
typedef pair<pii,pair<int,int>> qpi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX = 1e5;
const int MV = 1e5;
ll MA = -INF , MI = INF , ANS;

tpi prog[MAX+10];
int x;
bool vis[40];
tpi rec[40];
int siz = 0;

int32_t main()
{
	IO;
	int n , c;
	cin >> n >> c;
	
	for(int i=0 ; i<n ; i++)
		cin >> prog[i].F.F >> prog[i].F.S , cin >> prog[i].S;

	sort( prog , prog + n );
	
	qpi u , v;

	for(int i=0 ; i<n ; i++)
	{
		bool d = false;
		for( int j=0 ; j<siz ; j++)
		{
			if( rec[j].S == 0 )
				continue;
			else
			{
				if( rec[j].S == prog[i].S && !d )
					rec[j] = { { prog[i].F.F , prog[i].F.S } , prog[i].S } , d = 1;
				else if( rec[j].F.S <= prog[i].F.F - 0.5 && !d )
					rec[j] = { { prog[i].F.F , prog[i].F.S } , prog[i].S } , d = 1;
			}
		}
		if( !d )
			rec[siz++] = { { prog[i].F.F , prog[i].F.S } , prog[i].S };
	}
	
	cout << siz << "\n";
	return 0;
}

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

int main(int argc, char *argv[])
{
    int n;
    std::vector<int> a;

    std::cin >> n;

    a.resize(n);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    // 入力列の後ろが0なら切り落とす
    while(a[n - 1] == 0 && n > 0) {
        n--;
    }
    
    std::vector<char> b(n, 0);

    if (n == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }

    int count = 0;
    for (int i = n; i > 0; i--) {
        int sum = 0;
        for (int j = i; j <= n; j += i) {
            sum += b[j - 1];
        }
        if (sum % 2 != a[i - 1]) {
            b[i - 1] = 1;
            count++;
        }
    }


    std::cout << count << std::endl;

    for (int i = 0; i < n; i++) {
        if (b[i] == 1) {
            std::cout << (i + 1) << " ";
        }
    }

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s;cin>>s;
  ll ans=0;
  rep(i,4){
  	if(s[i]=='+'){
  	  ans++;
  	}else{
  		ans--;
  	}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

n,m = map(int,input().split())

d = {}
for i in range(n):
    arr = list(map(int,input().split()))
    for j in range(1,arr[0]+1):
        if not arr[j] in d:
            d[arr[j]] = 1
        else:
            d[arr[j]] += 1

ans = 0

for k in d.keys():
    if d[k] == n:
        ans += 1

# print(d)
print(ans)



Measured memory_bytes: 12396
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#define ll long long
using namespace std;

int main(){
	int n;
	int a[101];

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

	ll ans = 1000*1000;
	for (int i = -100; i < 101; ++i)
	{
		ll tmp = 0;
		for (int j = 0; j < n; ++j)
		{
			tmp += (a[j] - i) * (a[j] - i);
		}
		ans = min(tmp, ans);
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int N, M, Q;
int a[100], b[100], c[100], d[100];
vector<int> v;

void calc(int A, int endNum, int index){
   
   for (int i = 0; i <= endNum; i++) {
       int nextA = A + ( i * pow(10,index-1));
       if(index==N){
           v.push_back(nextA);
           return;
       }
       calc(nextA, i, index+1);
   }

}

int getVal(int val, int scale){
    for (int i = 0; i < scale; i++) {
        val /= 10;
    }
    return val%10;
}

int main() {

    cin >> N >> M >> Q;

    for (int i = 0; i < Q; i++) {
       int inA, inB, inC, inD;
       cin >> inA >> inB >> inC >> inD;
       a[i] = inA;
       b[i] = inB;
       c[i] = inC;
       d[i] = inD;
    }

    calc(0, M-1, 1);

    long ans = 0;
    for(auto val: v){
        long sumD = 0;
        for (int i = 0; i < Q; i++) {
            int valB = getVal(val, N-b[i]);
            int valA = getVal(val, N-a[i]);
            if( valB-valA==c[i]){
                sumD += d[i];
            }
        }
        ans = max(sumD, ans);

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


Measured memory_bytes: 4152
#include <iostream>
#include<cstdio>
#include <cctype>
#include<cstring>
using namespace std;

int main(){

    char str1[1000];
    while (true){
        scanf("%s", str1);

        if(str1[0]=='0') break;

        int i = strlen(str1);
        int num =0;
        for(int j =0;j<i;j++){
            num += str1[j] -'0';
        }
        printf("%d\n", num);
        
    }
}


Measured memory_bytes: 3164