akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

//Pizza
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int d = sc.nextInt();
			if(d==0)break;
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] p = new int[n];
			for(int i=1;i<n;i++)p[i]=sc.nextInt();
			Arrays.sort(p);
			int[] dest = new int[m];
			for(int i=0;i<m;i++)dest[i]=sc.nextInt();
			Arrays.sort(dest);
			int s = 0;
			int pos = 0;
			for(int i=0;i<m;i++){
				int min = Math.abs(p[pos%n]-dest[i]);
				if(min>d/2)min=d-dest[i]+p[pos%n];
				while(true){
					int v = Math.abs(p[(pos+1)%n]-dest[i]);
					if(v>d/2)v=d-dest[i]+p[(pos+1)%n];
					if(min<=v)break;
					min = v;
					pos++;
				}
				s+=min;
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N, K; cin >> N >> K;
	vector<int> p(N); rep(i, 0, N)cin >> p[i];
	int sum_max = 0; rep(i, 0, K)sum_max += p[i];
	int sum_tmp = sum_max;
	rep(i, K, N) {
		sum_tmp += p[i] - p[i - K];
		if (sum_tmp > sum_max)sum_max = sum_tmp;
	}
	double ans = (sum_max + K) / 2.;
	printf("%.7lf\n",ans);

	return 0;
}


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

using namespace std;

int main()
{
	int n;
	int count = 0;
	cin >> n;
	int ans = n;
	while (n > 0)
	{
		count += n%10;
		n /= 10;
	}
	if((ans%count) == 0)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
const int MOD = 1000000007;
int N,A[MAXN],x[MAXN],st[MAXN],ed[MAXN];
int64 cnt[MAXN],V[MAXN],D[MAXN],ID[MAXN],S,tr[MAXN],tr_cnt[MAXN],Inv_2,ans;
int64 fpow(int64 x,int64 c) {
    int64 res = 1,t = x;
    while(c) {
        if(c & 1) res = res * t % MOD;
        t = t * t % MOD;
        c >>= 1;
    }
    return res;
}
int lowbit(int x) {return x & (-x);}
void insert(int x,int64 v) {
    while(x <= N) {
        tr[x] += v;
        tr[x] %= MOD;
        tr_cnt[x]++;
        x += lowbit(x);
    }
}
int64 Query(int x,int64 v) {
    int64 res = 0;
    while(x > 0) {
        res += tr[x];
        x -= lowbit(x);
    }
    res %= MOD;
    return res * v % MOD;
}
int64 getnum(int x) {
    int64 res = 0;
    while(x > 0) {
        res += tr_cnt[x];
        x -= lowbit(x);
    }
    return res;
}
int64 Query_range(int L,int R,int64 v) {
    if(L == 0) ++L;
    if(L > R) return 0;
    return (Query(R,v) + MOD - Query(L - 1,v)) % MOD;
}
void Solve() {
    scanf("%d",&N);
    for(int i = 1 ; i <= N ; ++i) scanf("%d",&A[i]),cnt[A[i]]++;
    for(int i = N - 1; i >= 1 ; --i) cnt[i] += cnt[i + 1];
    S = 1;Inv_2 = (MOD + 1) / 2;
    for(int i = 1 ; i <= N ; ++i) {
        cnt[i] -= N - i;
        if(cnt[i] <= 0) {puts("0");return;}
        S = S * cnt[i] % MOD;
    }
    for(int i = 1 ; i <= N ; ++i) {
        V[i] = (cnt[i] - 1) * fpow(cnt[i],MOD - 2) % MOD;
    }
    D[0] = 1;
    st[0] = 0;
    for(int i = 1 ; i <= N ; ++i) {
        x[i] = x[i - 1];D[i] = D[i - 1];
        if(V[i] == 0) {x[i]++;st[x[i]] = i;ed[x[i] - 1] = i - 1;}
        else D[i] = D[i] * V[i] % MOD;
        ID[i] = fpow(D[i],MOD - 2);
    }
    ed[x[N]] = N;
    for(int i = 1 ; i <= N ; ++i) {
        ans += Query_range(st[x[A[i]]],A[i],D[A[i]] * S % MOD * Inv_2 % MOD);
        ans %= MOD;
        insert(A[i],ID[A[i]]);
    }
    memset(tr,0,sizeof(tr));
    memset(tr_cnt,0,sizeof(tr_cnt));
    for(int i = 1 ; i <= N ; ++i) {
        int64 t = Query_range(A[i] + 1,ed[x[A[i]]],ID[A[i]] * S % MOD * Inv_2 % MOD);
        ans += ((getnum(N) - getnum(A[i])) * S % MOD + MOD - t) % MOD;
        ans %= MOD;
        insert(A[i],D[A[i]]);
    }
    printf("%lld\n",ans);
}
 
int main() {
    Solve();
    return 0;
}

Measured memory_bytes: 12800
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int bitcount(int bits){
    int num;

    num = (bits >> 1) & 03333333333;
    num = bits - num - ((num >> 1) & 03333333333);
    num = ((num + (num >> 3)) & 0707070707) % 077;

    return num;
}

int n,m;
ll k;
string s;

int ans = 0;

int a[51];

struct UF{
	int data[51 * 2];
	int rk[51 * 2];
	int n;
	void init(int n){
		this->n = n;
		REP(i, n) {
			data[i] = i;
			rk[i] = 0;
		}
	}
	int find(int i){
		return i==data[i] ? i : data[i] = find(data[i]);
	}
	bool same(int a, int b){
		return find(a) == find(b);
	}
	void unite(int a, int b){
		a = find(a);
		b = find(b);
		if(a==b)return;
		if(rk[a] < rk[b]){
			data[a] = b;
		}else{
			data[b] = a;
			if(rk[a] == rk[b]) rk[b]++;
		}
	}
};

UF tree;

bool solve(int x){
	tree.init(n*2);
	REP(f, n) FOR(s, f+1, n){
		int p1 = abs(a[f] - a[s]);
		if(min(p1, 24 - p1) < x){
			tree.unite(f, s+n);
			tree.unite(f+n, s);
			if(tree.same(f, f+n)) return false;
			if(tree.same(s, s+n)) return false;
		}
		int p2 = abs(a[f] + a[s] - 24);
		if(min(p2, 24 - p2) < x){
			tree.unite(f, s);
			tree.unite(f+n, s+n);
			if(tree.same(f, f+n)) return false;
			if(tree.same(s, s+n)) return false;
		}
	}
	return true;
}

int main() {
	omajinai;
	cin >> n;
	REP(i, n) cin >> a[i+1];
	n++;

	int low=0, high=12;
	while(low<high){
		int mid = (low+high+1)/2;
		if(solve(mid)) low = mid;
		else high = mid - 1;
	}
	cout << low <<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N ;
  int t = 0;
  int x = 0;
  int y = 0;
  int able = 0;
  for (int i = 0; i < N; i ++) {
    int ti, xi, yi;
    cin >> ti >> xi >> yi;
    int p = ti - t ;
    int q = max (xi - x, x - xi);
    int r = max (yi - y, y - yi);//pqrの定義
    if (p < q + r) {
      able = 2;
      break;
    }
    for (int a = q; a <= p; a++) {
      int b = a - q;
      if (p < a + b) {
        able = 2;
        break;
      }
      for (int c = r; c <= p - a - b; c ++) {
        int d = c - r;
        if (p < c + d) {
          able = 2;
          break;
        }
        if (a + b + c + d == p) {
          able = 1;
          t = ti;
          x = xi;
          y = yi;
          break;
        }
        if (able) break;
      }
      if (able) break;
      able = 2;
    }
    if (able == 2) break;
  }
  if (able == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import math
def main():
    def pri(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a
    ans = 0
    a,b = map(int,input().split())
    c = pri(a)
    d = pri(b)
    p = []
    if len(c) > 0:
        p.append(c[0])
    for i in range(len(c)-1):
        if c[i] != c[i+1]:
            p.append(c[i+1])
    for i in range(len(p)):
        if p[i] in d:
            ans += 1
    print(ans+1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
signed main(){
  int n;cin>>n;
  cout<<kaijou(n)<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
#include<map>
#define int long long int
int32_t main()
{
	int n;
	cin>>n;
	multimap<int,int> mp;
	int j;
	for(j=0;j<n;j++)
	{
		int x,y;
		cin>>x>>y;
		mp.insert({y,x});
	}
	int curr=0;
	bool result=true;
	for(auto p:mp)
	{
		if(p.first>=p.second+curr)
		{
			curr+=p.second;
			continue;
		}
		else
		{
			result=false;
			break;
		}
	}
	if(result)
	   cout<<"Yes"<<endl;
	else
	   cout<<"No"<<endl;
}


Measured memory_bytes: 12800
#include <iostream>


using namespace std;


int main() 
{
 int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0  && w-r-x >=0 && h-r-y >=0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}







Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define V vector
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pair<int,int> >
#define VPL vector<pair<ll,ll> >
#define F first
#define S second
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,tr,fl) cout << ((c)? tr : fl) << endl

int main(){
    ins(n);
    VI p(n);
    rep(i,n)in(p.at(i));
    sortall(p);
    revall(p);
    int sum=p.at(0)/2;
    rep(i,n-1)sum+=p.at(i+1);
    print(sum);
    return 0;
}

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

int main() {
	int H, W; cin >> H >> W;
	vector<string> A(H);
	for (int i = 0; i < H; i++) cin >> A.at(i);
	int INF = 1000000000;
	vector<vector<int>> G(H, vector<int>(W, INF));
	queue<pair<int, int>> q;
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			if (A.at(y).at(x) == '#') {
				q.push(make_pair(y, x));
				G.at(y).at(x) = 0;
			}
		}
	}
	int ans = 0;
	vector<int> dx = { 0, 0, -1, 1 };
	vector<int> dy = { 1, -1, 0, 0 };
	while (!q.empty()) {
		int y = q.front().first;
		int x = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int ny = y + dy.at(i);
			int nx = x + dx.at(i);
			if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			if (G.at(ny).at(nx) != INF) continue;
			G.at(ny).at(nx) = G.at(y).at(x) + 1;
			ans = max(ans, G.at(ny).at(nx));
			q.push(make_pair(ny, nx));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #indef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    string s;
    cin>>s;
    int n =  s.size();
    for(int i = n-1 ; i>=0 ; i--)
    {
        if(s[i]!='?')
            continue;
        else
            s[i]='D';
    }
    cout<<s;

    printclock;
    return 0;
}


Measured memory_bytes: 3876
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
using namespace std;

const double pi=4*atan(1.0);


int main() {
	long long N,X;
	cin>>N>>X;

	long long ans=0;
	if(X<=N/2){
		ans+=N;
		long long a(N-X),b(X);
		while(1){
			if(a%b==0){
				ans+=b*(2*((a/b)-1)+1);
				break;
			}
			else{
				ans+=b*2*(a/b);
				long long tmp=a%b;
				a=b;
				b=tmp;
			}
		}
	}
	else{
		long long a(X),b(N-X);
		ans+=X;
		if(a%b==0){
			ans+=b*2*((a/b));
		}
		else{
			ans+=b*(2*(a/b)+1);
			long long tmp=a%b;
			a=b;
			b=tmp;
			while(1){
				if(a%b==0){
					ans+=b*(2*((a/b)-1)+1);
					break;
				}
				else{
					ans+=b*2*(a/b);
					long long tmp=a%b;
					a=b;
					b=tmp;
				}
			}
		}
	}
	cout<<ans<<endl;

	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modInv(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modInv(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int num=1;
int h,w;
vector<ll> sc,sd;
int c[400][400],ver[400][400];
void dfs(int x,int y,int color){
  ver[x][y]=num;
  if(c[x][y]==0)sc[num]++;
  else sd[num]++;
  for(int i=0;i<4;i++){
    int p=x+dx[i];
    int q=y+dy[i];
    if(p<0 || h<=p || q<0 || w<=q)continue;
    if(ver[p][q]!=0)continue;
    if(c[p][q]==color)continue;
    dfs(p,q,c[p][q]);
  }
}

int main(){
  int i,j,k,cnt=0;
  cin>>h>>w;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      char a;
      cin>>a;
      if(a=='.')c[i][j]=0;
      else c[i][j]=1;
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++)ver[i][j]=0;
  }
  sc.assign(2*h*w,0);
  sd.assign(2*h*w,0);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(ver[i][j]!=0)continue;
      dfs(i,j,c[i][j]);
      num++;
    }
  }
  ll ans=0;
  for(i=0;i<num;i++){
    ans+=sc[i]*sd[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 13952
n = int(input())
ab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[1])
t = 0
for i in range(n):
    t += ab[i][0]
    if t > ab[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 55260
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
//define MOD 1000000007000000
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

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

    int n;
    cin>>n;
    vector<int> b(n);
    vector<int> c(n);
    rep(i,n){
        cin>>b[i];
    }
    int memo;
    rep(i,n){
        int count=1;
        memo=1000;
        rep(j,n){
            if(b[j]==1000){
                continue;
            }

            if(count==b[j]){
                memo=j;
            }
            count++;
        }
        if(memo==1000){
            break;
        }
        c[i]=b[memo];
        //cout<<memo<<" ";
        b[memo]=1000;
    }

    

    if(memo==1000){
        cout<<-1<<endl;
    }
    else{
        for(int i=n-1;i>=0;i--){
            cout<<c[i]<<endl;
        }
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    vector <int> x(n), y(m);
    for(int i=0;i<n;++i) cin >> x[i];
    for(int i=0;i<m;++i) cin >> y[i];
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    int z[Y-X+1];
    int j=0;
    for(int i=X;i<=Y;++i) {
        z[j]=i;
        ++j;
    }
    bool ok=false;
    for(int i=0;i<=j;++i) {
        if(z[i]>X && z[i]<=Y) {
            if(z[i]>x[n-1] && z[i]<=y[0])
                ok=true;
        }
    }
    if(ok) cout << "No War" << endl;
    else cout << "War" << endl;
}


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

using int64 = long long;
using i64 = int64;

template<typename T>
using p_que = priority_queue<T>;
template<typename T>
using rp_que = priority_queue<T, vector<T>, greater<T>>;

constexpr int INF = (1 << 30) - 1;
constexpr int64 INF64 = (1ll << 60) - 1;

#define rep(i, N) for(int i=0;i<(int)(N);++i)
#define rep1(i, N) for(int i=1;i<=(int)(N);++i);
#define fs first
#define sc second
#define e_b emplace_back
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& m) {
	os << "{" << endl;
	for (auto& e : m) os << "(" << e.first << ", " << e.second << ")" << endl;
	return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
	os << "{" << endl;
	for (auto& e : s) os << ", " << e << endl;
	return os << "}";
}

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int64 gcd(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	int64 r;
	while ((r = y % x) != 0) {
		y = x;
		x = r;
	}
	return x;
}
int64 lcm(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	return x / gcd(x, y) * y;
}

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

void Main();
signed main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	Main();
}

/*----------------------------Insert from here!----------------------------*/

struct UnionFind {
    vector<int> data;
    
    UnionFind(int n) : data(vector<int>(n, -1)) {}
    
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    
    int find(int x) {
        if(data[x] < 0) return x;
        else return data[x] = find(data[x]);
    }
    
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    
    int size(int x) {
        return -data[find(x)];
    }
};

/*----------------------------Insert above here----------------------------*/

//const int MOD = 998244353;
//const int MOD = 1e9 + 7;
//const int MOD = 1234567;

void Main() {
    int n; cin >> n;
    int q; cin >> q;
    UnionFind tree(n);
    rep(i, q) {
        int com, x, y; cin >> com >> x >> y;
        if(com == 0) tree.unite(x, y);
        else cout << tree.same(x, y) << endl;
    }
}












Measured memory_bytes: 3240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] favorite = new int[m];
		for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		}
		int answer = 0;
		for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		}

		System.out.println(answer);
	}

}

Measured memory_bytes: 24276
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
#define int long long

void solve() {
	int n; cin >> n;
    int ans = 0;
    int p = 1;
    rep(i, n) {
        int a; cin >> a;
        if(a == p) {
            ++p;
        } else {
            ans += ((a - 1) / p);
            if(p == 1) p = 2;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


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

int main()
{
  int a, b;

  cin >> a >> b;

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


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

int main() {

    int N, D;
    std::cin >> N >> D;
    std::vector<std::vector<int>> X(N, std::vector<int>(D, 0));
    for (auto& v : X)for (auto& w : v)std::cin >> w;

    int ans = 0;

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

            int dis = 0;
            for (int d = 0; d < D; ++d) {
                int tmp = std::abs(X[i][d] - X[j][d]);
                dis += tmp * tmp;
            }
            int sq = std::sqrt(dis);
            if (sq * sq == dis)++ans;

        }
    }

    std::cout << ans << std::endl;

}

Measured memory_bytes: 256
n=int(input())
s=[]
for i in range(n):
    s.append(input())
m=int(input())
t=[]
for i in range(m):
    t.append(input())
x=0
for i in range(n):
    ben=s.count(s[i])-t.count(s[i])
    if ben>x:
        x=ben
print(x)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
  bool c[300001]={};
  for(int i=2;i<=300000;i++)if(i%7!=1&&i%7!=6)c[i]=1;
  for(int i=2;i*i<=300000;i++)
    if(!c[i])for(int j=2;j*i<=300000;j++)c[i*j]=1;
  while(cin>>n&&n!=1){
    cout<<n<<":";
    for(int i=6;i<=n;i++)
      if(!c[i]&&!(n%i))cout<<' '<<i;
    cout<<endl;
     }
  return 0;
}

Measured memory_bytes: 1460
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)


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

  if (N == 0) {
    cout << 0 << endl;
    return 0;
  }

  string s = "";
  while (N != 0) {
    if (abs(N % 2) == 1) {
      s += '1';
      N -= 1;
    } else
      s += '0';
    N /= -2;
  }

  reverse(ALL(s));
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)

{

  int a,b;

  scanf("%d %d", &a, &b);

  if( a < b )

    {

      printf("a < b\n");

    }

  if( a > b )

    {

      printf("a > b\n");

    }

  if( a == b )

    {

      printf("a == b\n");

    }

  return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
int sumOfEachDigit(int a){
	int sum = 0;
	while(a > 0){
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int main(){
  int in;
  cin >> in;
  (in % sumOfEachDigit(in) == 0) ? cout << "Yes" << endl : cout << "No" << endl;
}


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

using namespace std;
int main(void){
    int N;
    std::cin >> N;
    
    int tmp = 0;
    int result = 0;
    int prev = 0;
    
    for (int i = 0; i < N; i++) {
        int curr;
        std::cin >> curr;
        
        if (i == 0) {
            prev = curr;
            continue;
        }
        
        if (prev >= curr) {
          tmp++;
        } else {
          result = (result > tmp) ? result : tmp;
          tmp = 0;
        }

        prev = curr;
    }
    
    result = (result > tmp) ? result : tmp;
    
    std::cout << result << std::endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C,D;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    int X,Y;
    X=C/B;
    Y=A/D;
    if(C%B!=0)
        X+=1;
    if(A%D!=0)
        Y+=1;
    if(X<=Y)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 3764
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

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



	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		HashMap<Long, Long> map = new HashMap<Long, Long>();
		for(int i=0; i<n; i++) {
			long v = sc.nextLong();
			if(map.containsKey(v)) {
				map.put(v, map.get(v)+1);
			} else {
				map.put(v, 1L);
			}
		}
		long cnt = 0;
		for(Entry<Long, Long> v : map.entrySet()) {
			if(v.getValue() < v.getKey()) {
				cnt += v.getValue();
			} else {
				cnt += v.getValue()-v.getKey();
			}
		}
		System.out.println(cnt);
		sc.close();
	}

}


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

using namespace std;

    int a[100005];
    int b[100005];
    int bio[100005];
    vector<int> v[100001];
    deque<int> d;

int main (){

    int n,m;
    cin >> n >> m;

    for (int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }

    bio[1] = 1;
    d.push_back(1);

    while (true){
        int e = 0;
        int prvi = d.front();
        for (int i = 0; i < v[prvi].size(); i++){
            if (bio[v[prvi][i]] == 0){
                d.push_front(v[prvi][i]);
                bio[v[prvi][i]] = 1;
                e = 1;
                break;
            }
        }
        int zadnji = d.back();
        for (int i = 0; i < v[zadnji].size(); i++){
            if (bio[v[zadnji][i]] == 0){
                d.push_back(v[zadnji][i]);
                bio[v[zadnji][i]] = 1;
                e = 1;
                break;
            }
        }
        if (e == 0)break;
    }

    cout << d.size() << "\n";

    for (int i = 0; i < d.size(); i++){
        cout << d[i] << " ";
    }

    return 0;
}


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

wa = []
sa = []
for i in range(n):
    x, y = map(int, input().split())
    wa.append(x + y)
    sa.append(x - y)
wa.sort()
sa.sort()

print(max(abs(wa[0] - wa[-1]), abs(sa[0] - sa[-1])))


Measured memory_bytes: 99516
#include <iostream>

using namespace std;

const int INF = 1e9;

int main()
{
	int n, R;
	cin >> n >> R;

	int maxv = -INF, minv = R;
	for(int i = 1; i < n; i++) {
		cin >> R;
		if((R - minv) > maxv) maxv = R - minv;
		if(R < minv) minv = R;
	}

	cout << maxv << endl;

	return 0;
}


Measured memory_bytes: 3124
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;
int32_t step[3];

std::bitset<50> win;
std::bitset<101> passed[50];
std::vector<int32_t> graph[50];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M>> step [0]>> step[1] >> step[2];

	for (int32_t i = 0; i < M; i++)
	{
		int a, b;
		in >> a >> b;
		--a; --b;
		graph[b].push_back(a);
	}

	
	win[N - 1] = true;
	for (size_t COUNTCOUNTCOUNT = 0; COUNTCOUNTCOUNT < 50; COUNTCOUNTCOUNT++)
	{
		std::queue<std::pair<int32_t, int32_t>> que;
		for (size_t i = 0; i < N; i++)
		{
			if (win[i] && !passed[i][0]) {
				que.emplace(i, 0);
				passed[i][0] = true;
			}
		}

		while (!que.empty())
		{
			auto v = que.front(); que.pop();

			if (passed[v.first][step[0]] && passed[v.first][step[1]] && passed[v.first][step[2]]) {
				win[v.first] = true;
			}

			if (v.second < 100) {
				for (auto& i : graph[v.first])
				{
					if (!passed[i][v.second + 1])
					{
						que.emplace(i, v.second + 1);
						passed[i][v.second + 1] = true;
					}
				}
			}
		}
		if (win[0]) {
			out << COUNTCOUNTCOUNT+1 << endl;
			return 0;
		}
	}

	
	out << "IMPOSSIBLE" << endl;
	return 0;
}
#endif



Measured memory_bytes: 3220
//============================================================================
// Author       : Sun YaoFeng
//============================================================================

//#pragma 	comment(linker, "/STACK:100240000,100240000")
//#include	<cstdio>
//#include	<cstdlib>
//#include	<cstring>
//#include	<algorithm>

#include	<bits/stdc++.h>

using	namespace	std;

#define DB		double
#define	lf		else if
#define I64		long long
#define unt		unsigned int
#define	Rd()	(rand()<<15|rand())
#define For(i,a,b)	for(int i=(int)(a);i<=(int)(b);i++)
#define Rep(i,a,b)	for(int i=(int)(a);i>=(int)(b);i--)

#define	fi	first
#define se	second
#define MK	make_pair
#define pb	push_back
#define PA	pair<int, int>

//#define	min(a,b)	((a)<(b)?(a):(b))
//#define	max(a,b)	((a)<(b)?(b):(a))

#define	CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for	(; CH < '0' || ch > '9';)	f= (ch == '-');
		for	(; ch >= '0' && ch <= '9'; CH)	x= x*10 + ch -'0';
		return	f? -x : x;
}

#define n	205

I64		M;

int		N, A[n], B[n];

int		main(){
		cin >> M;
		
		int t= 0;
		for (; (1ll << t) - 1 <= M; t++);
		t--;
		
		M-= (1ll << t) - 1;
		
		N= t;
		For(i, 1, N)	A[i]= B[i]= i;
		
		Rep(d, t, 0)	{
			if	((1ll << d) <= M)	{
				M-= (1ll << d);
				
				N++;
				B[N]= N;
				
				Rep(i, N, d+2)	A[i]= A[i-1];
				A[d+1]= N;
			}
		}
		
		assert(M == 0);
		
		printf("%d\n", 2*N);
		For(i, 1, N)	printf("%d ", A[i]);
		For(i, 1, N)	printf("%d%c", B[i], " \n"[i == N]);
		
		return	0;
}

Measured memory_bytes: 256
s=list(input())
x,y=map(int,input().split())
f=0
t=0
s.append('T')
n=len(s)
xl=[]
yl=[]
for i in range(n):
    if s[i]=='F':
        f+=1
    else:
        if f>0:
            if t%2==0:
                if t==0:
                    x-=f
                else:
                    xl.append(f)
            else:
                yl.append(f)
            f=0
        t+=1
def solve(x,l):
    n=len(l)
    k=2*8000+1
    dp=[[-1 for p in range(k)] for q in range(n+1)]
    dp[0][k//2]=0
    for i in range(1,n+1):
        for j in range(k):
            if dp[i-1][j]>=0:
                dp[i][j-l[i-1]]=1
                dp[i][j+l[i-1]]=1
                #print(j)
    if dp[-1][x+k//2]>=0:
        return True
    else:
        return False
if solve(x,xl) and solve(y,yl):
    print('Yes')
else:
    print('No')
#print(xl,yl)


Measured memory_bytes: 404104
#include <stdio.h>

int main(void)
{
    int i, N;
    long l[87];
    l[0] = 2;
    l[1] = 1;
    scanf("%d", &N);
    for (i = 2; i <= N; i++) {
        l[i] = l[i - 1] + l[i - 2];
    }

    printf("%ld\n", l[N]);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;

int n, m;
int d[1000];
int c[1000];
int dp[1100][1100];
const int INF = 1001001000;

int main(){
	scanf("%d %d", &n, &m);
	for(int i=0; i<n; i++)
		scanf("%d", &d[i]);
	for(int i=0; i<m; i++)
		scanf("%d", &c[i]);

	for(int i=0; i<1000; i++)
		for(int j=0; j<1000; j++)
			dp[i][j] = INF;

	dp[0][0] = 0;
	dp[0][1] = d[0]*c[0];
	for(int i=1; i<m; i++){
		for(int j=0; j<n+1; j++){
			if(j == 0){
				dp[i][j] = dp[i-1][j];
			}else{
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-1] + d[j-1] * c[i]);
			}
		}
	}
	int ans = INF;
	for(int i=0; i<m; i++){
		ans = min(ans, dp[i][n]);
	}
	printf("%d\n", ans);
	return 0;
}

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

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

  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  string ans = (s < t) ? "Yes" : "No";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

#define MAX_N 200001
ll par[MAX_N];
ll nrank[MAX_N];

void init(ll n) {
	for (ll i = 0; i < n; i++) {
		par[i] = i;
		nrank[i] = 0;
	}
}

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

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

	if (nrank[x] < nrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (nrank[x] == nrank[y]) nrank[x]++;
	}
}

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

int main()
{
	ll n, m;
	cin >> n >> m;
	bool from1[200001],fromn[200001];

	for (ll i = 1; i <= n; i++) {
		from1[i] = false;
		fromn[i] = false;
	}


	//init(MAX_N);

	//for (ll i = 0; i < m; i++) {
	//	ll a, b;
	//	cin >> a >> b;
	//	unite(a, b);
	//}

	//if (same(1, n)) {
	//	cout << "POSSIBLE";
	//}
	//else {
	//	cout << "IMPOSSIBLE";
	//}

	for (ll i = 0; i < m; i++) {
		ll a, b;
		cin >> a >> b;

		if (a == 1) {
			from1[b] = true;
		}
		if (b == 1) {
			from1[a] = true;
		}
		if (a == n) {
			fromn[b] = true;
		}
		if (b == n) {
			fromn[a] = true;
		}
	}

	if (fromn[1] == true) {
		cout << "POSSIBLE";
		return 0;
	}
	else {
		for (ll i=1; i < n; i++) {
			if (from1[i] == true && fromn[i] == true) {
				cout << "POSSIBLE";
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE ";

	return 0;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void solve() throws IOException {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a - b >= 0)
			System.out.println("delicious");
		else if (a - b < 0 && a - b >= -x)
			System.out.println("safe");
		else if (a - b < -x)
			System.out.println("dangerous");

		sc.close();
	}

	public static void main(String[] args) {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    int ans=0;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        int x=i/10000+(i/1000)%10+(i/100)%10+(i/10)%10+i%10;
        if(a<=x&&x<=b)ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e6 + 5;
int n, dp[N], pre[N];
void add(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}
void rem(int &x, int y) {
	x -= y;
	if (x < 0) x += mod;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	dp[0] = 1;
	dp[1] = n;
	dp[2] = mul(n, n);
	
	fw (i, 0, 3) {
		pre[i] = i ? pre[i - 1] : 0;
		add(pre[i], dp[i]);
	}
	
	fw (i, 3, n + 1) {
		//a1 = 1
		add(dp[i], dp[i - 1]);
		
		//a1 = j, a2 = a3 = ... = a(j + 1) = 1.
		add(dp[i], pre[i - 3]);
//		//j = i to n will make 0.
		int cnt = n - i + 1;
		add(dp[i], cnt);
//		
		
		//a1 >= 2, a2 = a3 >= 2 => Everything is equal to a2 and a3.
		add(dp[i], mul(n - 1, n - 1));
		
		pre[i] = pre[i - 1];
		add(pre[i], dp[i]);
	}
	cout << dp[n];
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, M; cin >> N >> M;
  int A[N]; rep(i,N) cin >> A[i];
  int sum = 0; rep(i,N) sum += A[i];
  int count = 0; rep(i,N) if (A[i]*(4*M)>=sum) count++;

  string result = count>=M ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll power(ll x,ll y)
{
    ll res=1;
  
    while(y>0)
    {
        if(y&1)
            res=res*x;
        //res%=mod;
        y=y>>1;
        x=x*x;
        //x%=mod;
    } 
    return res; 
}
int main()
{
	FAST
	#ifdef ayk_16
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	ll n;
	cin>>n;
	ll a[n];
	vpl v[n];
	ll x,y,z;
	for(ll i=0;i<n;i++)
	{
		cin>>z;
		for(ll j=0;j<z;j++)
		{
			cin>>x>>y;
			x--;
			v[i].pb({x,y});
		}
	}
	ll b;
	ll ans=0;
	for(ll i=0;i<power(2,n);i++)
	{
		b=1;
		for(ll j=0;j<n;j++)
		{
			if((1<<j)&i)
			{
				for(auto k:v[j])
				{
					if((((1<<k.ff)&i)>>k.ff)!=k.ss)
					{
						b=0;
						break;
					}
				}
			}
			if(b==0)
				break;
		}
		if(b)
		{
			ll val=0;
			for(ll j=0;j<n;j++)
			{
				if(i&(1<<j))
					val++;
			}
			ans=max(val,ans);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
import math

a, b, x = list(map(int, input().split()))

if x <= 0.5 * a * a * b:
  c = 2 * x / a / b
  res = math.degrees(math.atan2(b, c))
else:
  d = (2 * (a * a  * b - x)) / (a ** 2)
  res = math.degrees(math.atan2(d, a))
print(res)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		if(s=="#") break;
		int ct=0,ct2=-1,len=s.size(),a[20]={0};
		while(ct<len){
			ct2++;
			if(s[ct]=='n'){
				a[ct2]=1;
				ct=ct+5;
			}
			else if(s[ct]=='w'){
				a[ct2]=2;
				ct=ct+4;
			}
		}
		int ue=0,shita=-1;
		for(int i=19;i>=0;i--){
			if(a[i]==1){
				shita++;
				if(shita!=0){
					ue=ue*2-45;
				}
			}
			else if(a[i]==2){
				shita++;
				ue=ue*2+45;
			}
		}
		if(shita==0) cout<<ue*2<<endl;
		else if(shita==1) cout<<ue<<endl;
		else cout<<ue<<"/"<<pow(2,shita-1)<<endl;
	}
    return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push(int );
void calc(char );

int top=1;
int s[100];

int main(){

  char num[4];
  int i,tmp,flag=0;
  
  while(1){
    if(scanf("%s",num) == EOF)break;
    
    flag =0;
    for(i=0;i<strlen(num);i++){//数字判定
      if(num[i]< '0'|| '9'< num[i])flag=1;
    }
    
    if(flag == 0)push(atoi(num));//数字
  
    if(num[0] == '+'|| num[0]== '-'|| num[0] == '*') calc(num[0]);//演算子
  
  }
  printf("%d\n",s[1]);
  
  return 0;
}

void push(int x){
  s[top]=x;
  // printf("入った数字%d\n",s[top]);
  top++;
}

void calc(char ope){
 top--;
  if(ope=='+')s[top-1] = s[top-1]+s[top];
  if(ope=='-')s[top-1] = s[top-1]-s[top];
  if(ope=='*')s[top-1] = s[top-1]*s[top];

  // printf("")

 
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
 
 
using namespace std;
 
static const int MAX = 200000;
 
int main() {
 
    int R[MAX],n;    
    cin >> n;
     
     
    for(int i = 0;i<n;i++){ 

      cin >> R[i];
 
 }
     
    int maxv = -2000000000;
     
    int minv = R[0];
 
    for (int i = 1;i < n; i++) {
         
        maxv = max(maxv, R[i] - minv );
         
        minv = min(minv, R[i]);
         
         
    }
     
    cout << maxv << endl;
 
 
 return 0;
}


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

const int N = 2e5+5;
ll n, k;
int a[N];
bool vis[N];
vector<int> path;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];

	memset(vis, 0, sizeof vis);
	int pos = 1;
	vis[pos] = 1;
	path.push_back(1);
	while(!vis[a[pos]] && k > 0)
		pos = a[pos], vis[pos] = 1, path.push_back(pos), k--;

	if(k == 0)
		cout << pos << '\n';
	else {
		int x = a[pos];
		int idx = 0;
		while(path[idx] != x) idx++;
		ll m = path.size() - idx;
		k = (k+m-1)%m;
		int p = 0;
		while(p < k) p++;
		cout << path[idx+p] << '\n';
	}

	return 0;
}

Measured memory_bytes: 5244
x = int(input())

while True:
    prime_flag = 1
    for i in range(2, int(x**0.5+1)):
        if x%i == 0:
            prime_flag *= 0
            break
    if not prime_flag:
        x += 1
        prime_flag = 1
    else:
        break
        
print(x)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 7;
typedef long long ll;
ll dp[maxn][maxn];
int vis[maxn][maxn];
char s[maxn][maxn];
//ll up = 0,left = 0;
ll dfs(int x,int y){
	if(x == 1&&y == 1) return 1ll;
	if(vis[x][y]) return dp[x][y] % mod;
	vis[x][y] = 1;
	if(s[x][y - 1] == '.') dp[x][y] = (dfs(x,y-1) + dp[x][y])%mod;
	if(s[x-1][y] == '.') dp[x][y] = (dfs(x - 1,y) + dp[x][y]) % mod;
	return dp[x][y] % mod;
}
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i = 1;i <= h;i++){
		scanf(" %s",s[i] + 1);
	}
	ll ans = dfs(h,w);
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int D;
  cin >> D;

  string ans;
  if (D == 25) {
    ans = "Christmas";
  } else if (D == 24) {
    ans = "Christmas Eve";
  } else if (D == 23) {
    ans = "Christmas Eve Eve";
  } else {
    ans = "Christmas Eve Eve Eve";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256