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

class RollingHash{
private:
    const std::vector<int_fast64_t> base = {1007, 2009, 3011};
    const std::vector<int_fast64_t> mod = {1000000007, 1000000009, 998244353};
    std::vector<int_fast64_t> hash[3], power[3];
public:
    RollingHash(){}
    RollingHash(const std::string& S){
        int_fast64_t len = S.length();
        for(int_fast64_t i = 0; i < 3; ++i){
            hash[i].assign(len+1, 0);
            power[i].assign(len+1, 1);
            for(int_fast64_t k = 0; k < len; ++k){
                hash[i][k+1] = (hash[i][k] * base[i] + S[k]) % mod[i];
                power[i][k+1] = (power[i][k] * base[i]) % mod[i];
            }
        }
    }
    
    inline std::vector<int_fast64_t> getHash(int_fast64_t l, int_fast64_t r) const {
        std::vector<int_fast64_t> hashes(3);
        for(int i = 0; i < 3; i++){
            int_fast64_t res = hash[i][r] - hash[i][l] * power[i][r-l] % mod[i];
            if(res < i) res += mod[i];
            hashes[i] = res;
        }
        return hashes;
    }

    inline int_fast64_t LCP(RollingHash& RH, int_fast64_t l1, int_fast64_t l2) const {
        int_fast64_t len = hash[0].size();
        int_fast64_t high = std::min(len - l1, len - l2) + 1;
        int_fast64_t low = 0;
        while(high - low > 1){
            int_fast64_t mid = (high + low) >> 1;
            if(getHash(l1, l1 + mid) == RH.getHash(l2, l2 + mid)) low = mid;
            else high = mid;
        }
        return low;
    }
};

using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    RollingHash A(S);
    using i64 = int_fast64_t;
    map<vector<i64>, int> mp;
    
    auto check = [&](i64 len) -> bool {
        for(int left=0;left+len<=N;left++){
            auto hashes = A.getHash(left, left+len);
            if(mp.count(hashes)){
                if(left - mp[hashes] >= len) return true;
            } else {
                mp[hashes] = left;
            }
        }
        return false;
    };

    i64 low = 0, high = N/2 + 1;
    while(high - low > 1){
        i64 mid = (low + high) >> 1;
        if(check(mid)) low = mid;
        else high = mid;
    }

    cout << low << endl;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
	int r,g,b,n;
	scanf("%d%d%d",&r,&g,&b);
	if(r>=1&&r<=9&&g>=1&&g<=9&&b>=1&&b<=9)
	{
		n=r*100+g*10+b;
		if(n%4==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

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

    if(a == b) cout << "H" << endl;
    else cout << "D" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

long long dfs(long long x) {
  if (x == 1) {
    return 1;
  }

  return 1 + dfs(x / 2) * 2;
}

int main() {
  long long n;
  cin >> n;
  cout << dfs(n) << endl;
}

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

using namespace std;

#define int long long
#define PB push_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

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

  int n, m;
  while (cin >> n >> m, n) {
    int dp[200][15][100] = {0};
    vector<pii> G[200];

    for (int i = 1; i <= n; ++i) {
      int k;
      cin >> k;
      for (int j = 0; j < k; ++j) {
        int x, d;
        cin >> x >> d;
        G[i].PB(pii(x, d));
      }
    }
    G[0].PB(pii(0, 0));
    G[n + 1].PB(pii(0, 0));

    fill(dp[1][0], dp[200][0], INF);
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; j < G[i].size(); ++j) {
        for (int k = 0; k <= m; ++k) {
          for (int dy = 1; dy <= 2; ++dy) {
            for (int j2 = 0; j2 < G[i + dy].size(); ++j2) {
              if (dp[i][j][k] == INF) continue;
              pii p1 = G[i][j], p2 = G[i + dy][j2];
              int move = abs(p1.first - p2.first), sumd = p1.second + p2.second;
              if (i == 0 || i + dy == n + 1) sumd = 0;
              dp[i + dy][j2][k + dy - 1] = min(dp[i + dy][j2][k + dy - 1], dp[i][j][k] + sumd * move);
            }
          }
        }
      }
    }

    int ans = INF;
    for (int i = 0; i <= m; ++i) {
      ans = min(ans, dp[n + 1][0][i]);
    }

    cout << ans << endl;
  }

  return 0;
}

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

static const int MAX = 600005;
bool is_prime[MAX];
 
void init_prime() {
  for (int i = 0; i < MAX; i++) is_prime[i] = true;
  is_prime[0] = false;
  is_prime[1] = false;
  int n = sqrt(MAX);
  for (int i = 2; i <= n; i++) {
    if (!is_prime[i]) continue;
    for (int j = i * 2; j < MAX; j += i) {
      is_prime[j] = false;
    }
  }
}

int main() {
    int X;
    cin >> X;
    init_prime();
    for (int i = X; i < MAX; i++) {
        if (is_prime[i]) {
            cout << i << "\n";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


int n;
string s;

int main(){
  cin>>n;
  cin>>s;
  int w = 0,e = 0;
  rep(i,n){
    if(s[i]=='W') w++;
  }

  int ans = n;
  rep(i,n){
    if(s[i]=='W'){
      ans = min(ans,n-w-e);
      w--;
    }
    if(s[i]=='E'){
      ans = min(ans,n-w-e);
      e++;
    }
  }
  ans = min(ans,n-w-e);

  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 900
#include <bits/stdc++.h>
#define watch(x) cerr << (#x) << " is " << (x) << " ";

using namespace std;
const int MAX = 100000;
int v[MAX];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> v[i];
	}
	
	map<int, int> evens;
	map<int, int> odds;
	
	for (int i = 0; i < n; i+=2){
		if (evens.count(v[i]) == 0){
			evens[v[i]] = 1;
		}
		else{
			evens[v[i]]++;
		}
	}
	for (int i = 1; i < n; i+=2){
		if (odds.count(v[i]) == 0){
			odds[v[i]] = 1;
		}
		else{
			odds[v[i]]++;
		}
	}
	
	if (evens.size() == 1 and odds.size() == 1){
		if (v[0] == v[1]){
			cout << n / 2 << endl;
		}
		else{
			cout << 0 << endl;
		}
	}
	else{
		int max_even = 0, second_max_even = 0;
		int max_even_element = -1, second_even_element = -1;

		for (auto it = evens.begin(); it != evens.end(); ++it){
			if (it->second > max_even){
				second_max_even = max_even;
				second_even_element = max_even_element;
				max_even = it->second;
				max_even_element = it->first;
			}
			else if(it->second > second_max_even){
				second_max_even = it->second;
				second_even_element = it->first;
			}
		}

		int max_odd = 0, second_max_odd = 0;
		int max_odd_element = -1, second_odd_element = -1;
		for (auto it = odds.begin(); it != odds.end(); ++it){
			if (it->second > max_odd){
				second_max_odd = max_odd;
				second_odd_element = max_odd_element;
				max_odd = it->second;
				max_odd_element = it->first;
			}
			else if (it->second > second_max_odd){
				second_max_odd = it->second;
				second_odd_element = it->first;
			}
		}
		if (max_even_element != max_odd_element){
			cout << (n - max_even - max_odd) << endl;
		}
		else{
			int ans1 = (n - max_even - second_max_odd);
			int ans2 = (n - max_odd - second_max_even);
			cout << min(ans1, ans2) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    int f,m,th,u;
    f=s1[0];
    u=64;
    for(int l=97;l<123;l++){
            u++;
            if(f==l)
                s1[0]=u;
    }
    printf("%c",s1[0]);
    m=s2[0];
    u=64;
    for(int l=97;l<123;l++){
            u++;
            if(m==l)
                s2[0]=u;
    }
    printf("%c",s2[0]);
    th=s3[0];
    u=64;
    for(int l=97;l<123;l++){
            u++;
            if(th==l)
                s3[0]=u;
    }
    printf("%c",s3[0]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << endl;
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef pair<float, float> ff;
const int Nmax = 100001;
int n, m;
vector<int> graph[Nmax], num;
void DFS(const int &u)
{
	int res = 0;
	bool check = false;
	for(int &v : graph[u]) {
		check = true;
		if (!num[v]) {
			DFS(v);
			res = max(res, num[v]);
		}
		else res = max(res, num[v]);
	}
	if (!check) num[u] = 1;
	else num[u] = 1 + res;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int u, v;
	scanf("%d %d", &n, &m);
	num.resize(n + 1, 0);
	REP0(t, m) {
		scanf("%d %d", &u, &v);
		graph[u].pb(v);
	}
	REP1(i, n) if (!num[i]) DFS(i);
	cout << *max_element(num.begin() + 1, num.end()) - 1;
	return 0;
}

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

using namespace std;
const int mod = (int)1e9+7;
int n,m;
string mat[1005];
int dp[1005][1005];

int  safe(int x, int y) {
    if (x > n || y > m  || y < 0 || x < 0)return 0;
    return 1;
}

int solve(int x, int y) {
    if (x > n || y >  m || y < 0 || x < 0)return 0;
    if (x == n-1 && y == m - 1 && mat[x][y] != '#')return 1;
    if (mat[x][y] == '#')return 0;

    if (dp[x][y] != -1)return dp[x][y];
    int ans = 0;
    if (safe(x+1,y) && mat[x+1][y] !='#')  {
        ans += solve(x+1,y);
        ans %= mod;
    }
    if (safe(x,y+1) && mat[x][y+1] != '#') {
        ans += solve(x,y+1);
        ans %= mod;
    }

    return dp[x][y] = ans%mod;
}
int main() {
    cin >> n >> m;
    
    for (int i = 0; i < n; i++) {
        cin >> mat[i];
    }
    memset(dp,-1,sizeof(dp));

    int ans = solve(0,0);
    cout << ans%mod << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    if(a <= c && c <= b) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 4e5 + 111;
     
using namespace std;

ll n, q, k, a[maxn], ans = inf;

void solve(){     
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> a[i];

	sort(a + 1, a + n + 1);

	int l = a[1], r = a[n];

	for (int i = l; i <= r; i++){
		ll x = 0;
		for (int j = 1; j <= n; j++)
			x += (a[j] - i) * (a[j] - i);
		ans = min(ans, x);
	}

	cout << ans;
}

main(){
    boost;
	                 	
	q = 1;

	while (q--){
		solve();
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
  int k;
  cin>>k;
  int a,b,flag=0;
  cin>>a>>b;
  if(k==1)
    cout<<"OK"<<endl;
  else if((b-a)>=k)
    cout<<"OK"<<endl;
  else 
  {
    for(int i=a;i<=b;i++){
      if(i%k==0){
        flag=1; 
        break;}
    }
    if(flag==1)cout<<"OK"<<endl;
    else
       cout<<"NG"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 1e5;

vector<lld> fact,inv;


lld pow(lld a,lld b, lld p)  // a^b mod pを求める
{
	if (b == 0)
	{
		return 1;
	}else if (b % 2 == 0)
	{
		lld d = pow(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return ((d%mod) * d) % mod;
	}else
	{
		return ((a%mod) * pow(a,b-1,p) % mod)%mod;
	}
}

void init(lld n)
{
	fact.resize(n+1,1);
	inv.resize(n+1,1);

	for(int i = 1; i <= n; i++)  //　nまでの階乗を求める
	{
		fact[i] = fact[i-1] * i % mod;
	}
	// for(int i = 1; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p
	// {
	// 	inv[i] = f(fact[i],mod-2,mod) % mod;
	// }
}

lld comb(lld n,lld k)  //n_C_k
{
	if (n < k)
	{
		return 0;
	}
	return ((fact[n]%mod) * (pow(fact[k],mod-2,mod) % mod ) %mod) * (pow(fact[n-k],mod-2,mod)% mod) % mod;
}


int main()
{
	lld n;

	cin >> n;

	if (n == 1)
	{
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	vector<lld> a(n+2);

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

	lld same=0,sum=0;

	set<lld> s;
	for(lld i = 1; i <= n+1; i++)
	{
		if (s.count(a[i]))
		{
			same = a[i];
			break;
		}else
		{
			s.insert(a[i]);
		}
	}

	//cout << "same = " <<  same << endl;

	lld left=0,right=0;
	bool ch = false;

	for(lld i = 1; i <= n+1; i++)
	{
		if (a[i] == same)
		{
			if (!ch)
			{
				left = i;
				ch = true;
			}else
			{
				right = i;
				break;
			}
		}
	}
	//cout << "left = " << left << " right = " << right << endl;

	lld del = left + n - right;

	//cout << "del = " << del << endl;

	init(n+2);

	for(lld i = 1; i <= n+1; i++)
	{
		// cout << "n+1 = " << n+1 << " i = " << i << " ";
		// cout << comb(n+1,i) % mod << " - " << comb(n-right+left,i-1) << " = ";
		cout << (comb(n+1,i) - comb(n-right+left,i-1) + mod)%mod << endl;
	}

	// for(int i = del+1; i <= n+1; i++)
	// {
	// 	cout << comb(n+1,i) % mod << endl;
	// }
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define endl "\n"
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define ll long long
#define llu unsigned long long
#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
#define ABS(X) ((X)< 0 ? -(X): (X))
#define LCM(X, Y)  ( ( (X) / (GCD( (X)  , (Y) ))) * (Y) )
#define MEM( A,  B) memset((A), (B), sizeof(A))
#define MEM_VEC(V, FILL ) fill( V.begin(), V.end(), FILL)
#define FOR_EACH(IT, V) for (auto IT = V.begin(); IT != V.end(); IT++)
#define DEBUG_ARRAY_PRINT(A,I) cout<<"at pos "<< I <<"  value is: "<< A[I]
#define TURBO ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0)
const double EPS =1e-9 ;
const double PI = 3.1415926535897932384626433832795 ;
using namespace std ;
inline ll GCD(ll A, ll B){
      if ( B == 0 ) return A;
      return GCD( (B) ,  (A % B) );
}
inline ll POW(ll BASE, ll EXP) {
   ll RES = 1;
   for(ll I= 0; I < EXP; I++) RES *= BASE ;
   return RES;
}

inline ll BIGMOD  ( ll a, ll p, ll m ) {
   ll res = 1 % m;
   ll x = a % m;
   while ( p > 0 ) {
       if ( (p & 1) > 0 ) res = ( res * x ) % m;
       x = ( x * x ) % m; p >>= 1;
   }
   return res;
}
inline void FILE_HANDLE( ){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}

int main()
{
            TURBO;
            //FILE_HANDLE() ;
            string num ;
            cin >> num ;

            int sum = 0 ;
            for(int i = 0 ; i < num.size() ; i++)
            {
                 sum = sum * 10 + (num[i] - '0') ;
                 sum %= 9;

            }
           // cout << sum << endl ;
            if(!sum) cout <<"Yes\n" ;
            else cout <<"No\n" ;
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;
	vector<ll>v;
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> x;
		v.pb(x);
	}
	sort(all(v));
	reverse(all(v));

	ll ans=-v[0];
	for(i=0;i<n/2;i++)
		ans+=2*v[i];

	if(n%2)
		ans+=v[n/2];
	cout<<ans<<endl;
}

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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int ans = 0, x = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'I') {
      x++;
    }
    else {
      x--;
    }
    if (ans < x) {
      ans = x;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int,input().split()))

a = []
a.append(b[0])  # 左端
for i in range(1,n-1):
  x = min(b[i-1],b[i])
  a.append(x)  # 小さい方を格納
a.append(str(b[n-2]))  # 右端
N = 0
for i in range(n):
  N = N + int(a[i])
print(N)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int head[N],son[N],father[N];
bool dp[N];
int n,x,y;
struct Tree{
    int nxt,to;
}e[500005];
int k=0;
void add(int x,int y){e[++k].nxt=head[x];e[k].to=y;head[x]=k;}
void dfs2(int u,int fa)
{
    son[u]=1;
    for (int i=head[u];i;i=e[i].nxt){
        int v=e[i].to;
        if (v==fa) continue;
        dfs2(v,u);
        son[u]=son[u]+son[v]; father[v]=u;
    }
}
bool flag=false;
void dfs(int u,int fa)
{
    if (son[u]==1){
    	dp[u]=true;
    	return;
	}
	int tot=0;
    if (flag) return;
    for (int i=head[u];i;i=e[i].nxt){
        int v=e[i].to;
        if (v==father[u]) continue;
        dfs(v,u);
        if (dp[v]==true) tot++;
        if (tot>=2){
            flag=true;
            return;
        }
        dp[u]=dp[u]^dp[v];
    }
    dp[u]=!dp[u];
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        add(x,y); add(y,x);
    }
    dfs2(1,-1); dfs(1,-1);
    if (flag||dp[1]) puts("First");
    else puts("Second");
    return 0;
}

Measured memory_bytes: 9984
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n[][] = new int[3][3];
		int total = 0;
		for(int i = 0;i<3;i++){
			for(int j = 0;j<3;j++){
				int a = sc.nextInt();
				total+=a;
				n[i][j] = a;
			}
		}String ans = "Yes";
		for(int i = 0;i<1;i++){
			if(total%3!=0){
				ans = "No";break;
			}total/=3;
			if((n[0][0]+n[1][1]+n[2][2])!=total||(n[0][2]+n[1][1]+n[2][0])!=total){
				ans = "No";break;
			}
		}System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int x, t;
    cin >> x >> t;
    if (x > t) {
        cout << x - t << "\n";
    } else {
        cout << 0 << "\n";
    }
}

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

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

    long negativeCount=0;
    for (long i=a; i<b+1; ++i) {
        if (i==0) {
            cout << "Zero" << endl;
            return 0;
        } else if (i<0) {
            ++negativeCount;
        }
    }

    if (negativeCount%2 == 1) {
        cout << "Negative" << endl;
        return 0;
    } else {
        cout << "Positive" << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String a=sc.next();
            if(a.equals("0")){
                break;
            }
            int sum=0;
for(int j=0;j<a.length();j++){
    sum+=a.charAt(j)-'0';
}
System.out.println(sum);
        }
        sc.close();
    }
}


Measured memory_bytes: 26480
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int W,H,N,x,y,a,ans;

int main(){
    cin>>W>>H>>N;
    int S[H][W];
    rep(i,H){
        rep(j,W){
            S[i][j]=1;
        }
    }
    rep(i,N){
        cin>>x>>y>>a;
        if(a==1){
            rep(i,H){
                rep(j,x){
                    S[i][j]=0;
                }
            }
        }
        else if(a==2){
            rep(i,H){
                repi(j,x,W){
                    S[i][j]=0;
                }
            }
        }
        else if(a==3){
            rep(i,y){
                rep(j,W){
                    S[i][j]=0;
                }
            }
        }
        else{
            repi(i,y,H){
                rep(j,W){
                    S[i][j]=0;
                }
            }
        }
    }
    rep(i,H){
        rep(j,W){
            ans+=S[i][j];
        }
    }
    out(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	double H, A;
	cin >> H >> A;

	cout << ceil(H / A) << endl;

	return 0;
}


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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int64_t N, X, M;
    cin >> N >> X >> M;
    static int64_t sum[40][100000], nxt[40][100000];
    for(int64_t i=0; i<M; i++){
        sum[0][i] = i;
        nxt[0][i] = i*i%M;
    }
    for(int k=0; k<39; k++) for(int i=0; i<M; i++){
        sum[k+1][i] = sum[k][i] + sum[k][nxt[k][i]];
        nxt[k+1][i] = nxt[k][nxt[k][i]];
    }

    int64_t ans = 0;
    for(int k=39; k>=0; k--) if(nth_bit(N, k)){
        ans += sum[k][X];
        X = nxt[k][X];
    }
    cout << ans << endl;
    return 0;
}


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

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<double> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  vector< vector<double> > dp(n, vector<double>(n + 1, 0.0));
  dp[0][0] = 1.0 - p[0];
  dp[0][1] = p[0];
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n; j++) {
      dp[i + 1][j] += dp[i][j] * (1.0 - p[i + 1]);
      dp[i + 1][j + 1] += dp[i][j] * p[i + 1];
    }
  }
  double ans = 0.0;
  for (int i = n; i > n - i; i--) {
    ans += dp[n - 1][i];
  }
  cout << fixed << setprecision(10) << ans << '\n';
  return 0;
}

Measured memory_bytes: 70656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
#define ld double
const ll N = 3e2 + 5;
ld dp[N][N][N];
ll n, memo[N][N][N];
ld doit(ll c1, ll c2, ll c3) {
	if(!c1 && !c2 && !c3) return 0.0;
	ld &ret = dp[c1][c2][c3];
	if(memo[c1][c2][c3]) return ret;
	memo[c1][c2][c3] = 1;
	ld p1 = (ld)c1 / n, p2 = (ld)c2 / n;
	ld p3 = (ld)c3 / n, p0 = (ld)(n - c1 - c2 - c3) / n;
	ld ans = 1;
	if(c1) ans += p1 * doit(c1 - 1, c2, c3);
	if(c2) ans += p2 * doit(c1 + 1, c2 - 1, c3);
	if(c3) ans += p3 * doit(c1, c2 + 1, c3 - 1); 
	ans /= (1 - p0);
	return ret = ans;
}
int main() {

    localTest();
    fastio;
 	map<ll, ll> has;
 	cin >> n;
 	vector<ll> A(n);
 	for(auto &x : A) cin >> x, has[x]++;
 	cout << setprecision(10) << doit(has[1], has[2], has[3]) << "\n";
    return 0;
}

Measured memory_bytes: 221312
import numpy as np

N = int(input())

A = []
for i in range(N):
    num = float(input()) * 10 ** 9 + 0.5
    A.append(int(num))


def count2(n):
    ret = 0
    while(n % 2 == 0):
        ret += 1
        n /= 2
    return ret


def count5(n):
    ret = 0
    while(n % 5 == 0):
        ret += 1
        n /= 5
    return ret


table = {}
for i in range(19):
    for j in range(19):
        table[i, j] = 0

for a in A:
    c2 = count2(a)
    c5 = count5(a)
    if(c2 > 18):
        c2 = 18
    if(c5 > 18):
        c5 = 18
    table[c2, c5] += 1

res = 0
for i in range(19):
    for j in range(19):
        for k in range(19):
            for l in range(19):
                if i + k >= 18 and j + l >= 18:
                    if i == k and j == l:
                        res += table[i, j] * (table[i, j] - 1)
                    else:
                        res += table[i, j] * table[k, l]

print(res // 2)


Measured memory_bytes: 34924
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i]-'0');
	}
	return d;
}
ll H, W;
int main()
{
	cin >> H >> W;
	ll ans = 0;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
		return 0;
	}
	for(int i=0;i<W;i+=2) {
		ans += min(H, W - i);
		
	}
	for (int i = 2; i < H;i+=2) {
		ans += min(H - i, W);
		
	}
	cout << ans << endl;
}

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

typedef long long ll;

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

    int n, x, y;
    cin >> n >> x >> y;

    vector<int> counts(n);
    //map<pair<int, int>, int> m;

    for (int i = 1; i < n + 1; ++i) {
        for (int j = 1; j < n + 1; ++j) {
            int diff1 = abs(i - j);
            int diff2 = abs(i - x) + 1 + abs(j - y);
            int diff3 = abs(i - y) + 1 + abs(j - x);

            int mini = min({diff1, diff2, diff3});
            counts[mini]++;
            //m[make_pair(i, j)] = mini;
        }
    }

    //for (auto pp: m) {
        //cout << pp.first.first << ", " << pp.first.second << ": " << pp.second << "\n";
    //}

    //cout << "\n";
    //cout << "\n";

    for (int i = 1; i < n; ++i)
        cout << counts[i] / 2 << "\n";

    cout << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define FI first
#define SE second
using namespace std;
typedef pair<int,int> pii;
static const int inf = 1ll<<60;

int N,A;
int x[55];
int ans;
int mem[52][52][2501][2];

int cal2(int n,int use,int sum,int b){
    if(mem[n][use][sum][b]!=-1)return mem[n][use][sum][b];
    int res=0;
    if(n==N+1){
        return 0;
    }
    if(use!=0&&b){
        if((double)sum/use==A){
            res+=cal2(n+1,use+1,sum+x[n],1)+cal2(n+1,use,sum,0)+1;
        }
        else res+=cal2(n+1,use+1,sum+x[n],1)+cal2(n+1,use,sum,0);
    }
    else{
        res+=cal2(n+1,use+1,sum+x[n],1)+cal2(n+1,use,sum,0);
    }
    return mem[n][use][sum][b]=res;
}


signed main(){
    cin>>N>>A;
    memset(mem,-1,sizeof(mem));
    for(int i=0;i<N;++i)cin>>x[i];
    ans=cal2(0,0,0,true);
    cout<<ans<<endl;
}


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

int main() {
  int a,b,c,d,e,f;
  cin>>a>>b>>c;
  d=min(a,min(b,c));
  f=max(a,max(b,c));
  e=a+b+c-d-f;
  if(d==e && !(e==f)){
    cout<<"Yes"<<endl;
  }
  else if(e==f && !(d==e)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <cstring>
#include <climits>
#define INF INT_MAX / 2
using namespace std;

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

vector<int> cut(vector<int> vi,int p,int c){
	vector<int> ret;
	for(int i=p-1;i<p-1+c;i++)
		ret.push_back(vi[i]);
	for(int i=0;i<p-1;i++)
		ret.push_back(vi[i]);
	for(int i=p+c-1;i<vi.size();i++)
		ret.push_back(vi[i]);
	return ret;
}

int main(void) {
	int n;int r;

	while(cin >> n >> r,n+r!=0){
	vector<int> a(n);
	for(int i=0;i<n;i++)
		a[i] = n-i;

	for(int i=0;i<r;i++){
		int p,c;
		cin >> p >> c;
		a = cut(a,p,c);
	}
	cout << a[0] << endl;
}
}

// command ctrl 上下
// command D
// command caps G → '' ""

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li n, k;
li a[2020];

int main() {
    cin >> n >> k;
    li self = 0;
    rin{
        cin >> a[i];
        rep(j, i) {
            if (a[j] > a[i]) {
                self++;
            }
        }
    }
    li opp = 0;
    rin{
        rep(j, n) {
            if (a[j] < a[i]) {
                opp++;
            }
        }
    }
    li self2 = self * k % MOD;
    li opp2 = opp * (k * (k - 1) / 2 % MOD) % MOD;
    cout << (self2 + opp2) % MOD << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

//		Scanner s = new Scanner(System.in);
		int arrayCnt = Integer.parseInt(br.readLine());
		int[] array = new int[arrayCnt];
		String[] tmpArray = br.readLine().split(" ");
		for(int i=0 ; i<array.length ; i++) {
			array[i] = new Integer(tmpArray[i]).intValue();
		}

		int cc = sort(array, 0, array.length-1);
		StringBuilder sb = new StringBuilder();
		for(int i=0 ; i<array.length ; i++) {
			sb.append(array[i]).append(" ");
		}
		System.out.println(sb.toString().trim());
		System.out.println(cc);
	}

	public static int sort(int[] array, int start, int end) {
		int c = 0;
		if(start < end){
			int mid = (start+end)/2;
			c += sort(array, start, mid);
			c += sort(array, mid+1, end);
			c += merge(array, start, end);
		}
		return c;
	}

	public static int merge(int[] array, int start, int end) {
		int cnt = 0;
		int mid = (start+end) / 2;
		int[] left = new int[mid-start+2];
		int[] right = new int[end-mid+1];
		for(int i=0 ; i<left.length-1 ; i++) {
			left[i] = array[start+i];
		}
		for(int j=0 ; j<right.length-1 ; j++) {
			right[j] = array[mid+j+1];
		}
		int l = 0;
		int n = 0;
		left[mid-start+1] = Integer.MAX_VALUE;
		right[end-mid] = Integer.MAX_VALUE;
		for(int k=0 ; k<left.length+right.length-2 ; k++) {
			if(left[l] > right[n]) {
				array[start] = right[n];
				n++;
			}else{
				array[start] = left[l];
				l++;
			}
			cnt++;
			start++;
		}
		return cnt;
	}
}

Measured memory_bytes: 182016
n = gets.to_i

lucas = "1
3
4
7
11
18
29
47
76
123
199
322
521
843
1364
2207
3571
5778
9349
15127
24476
39603
64079
103682
167761
271443
439204
710647
1149851
1860498
3010349
4870847
7881196
12752043
20633239
33385282
54018521
87403803
141422324
228826127
370248451
599074578
969323029
1568397607
2537720636
4106118243
6643838879
10749957122
17393796001
28143753123
45537549124
73681302247
119218851371
192900153618
312119004989
505019158607
817138163596
1322157322203
2139295485799
3461452808002
5600748293801
9062201101803
14662949395604
23725150497407
38388099893011
62113250390418
100501350283429
162614600673847
263115950957276
425730551631123
688846502588399
1114577054219522
1803423556807921
2918000611027443
4721424167835364
7639424778862807
12360848946698171
20000273725560978
32361122672259149
52361396397820127
84722519070079276
137083915467899403
221806434537978679
358890350005878082
580696784543856761
939587134549734843
1520283919093591604
2459871053643326447
3980154972736918051
6440026026380244498
10420180999117162549
16860207025497407047
27280388024614569596
44140595050111976643
71420983074726546239
115561578124838522882
186982561199565069121
302544139324403592003
489526700523968661124
792070839848372253127".split(" ")

puts lucas[n-1]

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a==c-b){
    cout << "YES" << endl; 
  }
  else{
    cout << "NO" << endl;
  }
}
  
  
  
  
  

  



Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, A, B;
	cin >> N >> A >> B;
	if(N > 1LL*A*B || N < A+B-1) {
		cout << "-1\n";
		return 0;
	}
	vector<int> seq(A, 1);
	int sum = A;
	for(int i = 0; i < A; i++) {
		int x = min(B-1, N-sum);
		seq[i] += x;
		sum += x;
	}
	sum = 0;
	vector<int> ans;
	for(int i = 0; i < A; i++) {
		for(int j = 0; j < seq[i]; j++) ans.push_back(sum+seq[i]-j);
		sum += seq[i];
	}
	for(int i = 0; i < N; i++) cout << ans[i] << ((i == N-1)?"\n":" ");
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

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

    vector<int> A(n);
    rep(i,n) cin >> A[i];

    vector<vector<ll>> dp(n+1, vector<ll>(2,0));
    dp[0][0] = 1;

    rep(i,n){
        rep(j,2){
            dp[i+1][j] += dp[i][j];
            dp[i+1][(j+A[i])%2] += dp[i][j];
        }
    }

    cout << dp[n][p] << endl;
    
}


Measured memory_bytes: 3564
import java.io.*;

public class Main {
  
  static String s;

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    s = br.readLine();

    br.close();

    boolean ok = true;
    if(s.charAt(2) != s.charAt(3)) ok = false;
    if(s.charAt(4) != s.charAt(5)) ok = false;
    System.out.println(ok ? "Yes" : "No");
  }
}

Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    S = input().strip()
    T = input().strip()
    if S == T[:-1]:
        print("Yes")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, k, u, d;

int main() {
	cin >> n >> m >> k;
	rept(i,n) {
		u = k - i*m;
		d = n - 2*i;
		if (d!=0 && u%d==0 && 0<=u/d && u/d<=m) {
			cout << "Yes" << ln;
			return 0;
		}
	}
	cout << "No" << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
ll f[101010],rf[101010];
ll inv(ll x) {
    ll res=1;
    ll k=mod-2;
    ll y=x;
    while(k){
        if(k&1) res=(res*y)%mod;
        y=(y*y)%mod;
        k/=2;
    }
    return res;
}
void init() {
    f[0]=1;
    for(ll i=1;i<101010;i++) f[i]=(f[i-1]*i)%mod;
    for(ll i=0;i<101010;i++) rf[i]=inv(f[i]);
}
ll comb(ll n, ll k) {
    ll a=f[n]; // = n!
    ll b=rf[n-k]; // = (n-k)!
    ll c=rf[k]; // = k!
    ll bc=(b*c)%mod;
    return (a*bc)%mod;
}
int main(){
  ll n,k;
  cin >>n>>k;
  init();
  for(ll i=1;i<=k;i++){
    if(i>n-k+1) cout <<0<<endl;
    else cout <<(comb(n-k+1,i)*comb(k-1,i-1))%mod<<endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
#ifdef kvutxdy
    freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/test/input.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    for (ll &x : a) cin >> x;
    sort(a.begin(), a.end());
    ll sum = accumulate(a.begin(), a.end(), 0LL);
    reverse(a.begin(), a.end());
    ll prefix = 0LL, res = sum;
    for (int i = 0; i < min(N, K); ++i) {
        res = min(res, sum - (prefix += a[i]));
    }
    cout << res;
}

Measured memory_bytes: 1792
#define N 12
double M[N][1<<N],r,t;
D[N],n;
double dfs(p,f){if(M[p][f]<0){
	int i=0;
	M[p][f]=0;
	for(;i<n;i++)if(!(f&1<<i)&&(t=dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]),M[p][f]<t))M[p][f]=t;
}return M[p][f];}
main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r<=l?"OK":"NA")){
	for(d=n=0;getchar()!='\n';d+=D[n++]*2)scanf("%d",D+n);
	for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
	for(r=i=0;i<n;i++)if(t=dfs(i,1<<i),r<t)r=t;
}exit(0);}

Measured memory_bytes: 968
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
s=[[0] * k for i in range(n)]
for i in range(k):
  input()
  l=list(map(int, input().split()))
  for j in range(len(l)):
    s[l[j]-1][i]=1

r=0
for i in range(n):
  if sum(s[i])==0:
    r=r+1
print(r)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main(void){

  int N, M;  cin >> N >> M;
  vector<vector<int>>  edge(N);   //添字 : from, 値 : to

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

  bool ans = false;
  for(int i = 0 ; i < edge[N - 1].size() ; i++){

    int to = edge[N - 1][i];
    for(int j = 0 ; j < edge[to].size() ; j++){
      if(edge[to][j] == 0){
        ans = true;
        break;
      }
    }

    if(ans)  break;
  }

  if(ans)  cout << "POSSIBLE"   << endl;
  else     cout << "IMPOSSIBLE" << endl;

  return 0;
}

Measured memory_bytes: 12016
#include <iostream>
#include <algorithm>

#define INF 1000000

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int dp[n][n];
    bool edge[n][n];
    fill(dp[0], dp[n], INF);
    fill(edge[0], edge[n], 0);
    for (int i=0; i<n; i++) dp[i][i] = 0;
    for (int i=0; i<m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dp[a][b] = c;
        dp[b][a] = c;
        edge[a][b] = true;
        edge[b][a] = true;
    }
    int cnt = 0;
    for (int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                if (dp[i][j] > dp[i][k] + dp[k][j] && edge[i][j]) {
                    edge[i][j] = false;
                    edge[j][i] = false;
                    cnt++;
                }
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 256
// 3以上あるやつはオナニーすれば奇数だと1枚 偶数だと2枚にできる
// 2が偶数枚 -> 全部とれそう
// 奇数枚 -> 1枚減りそう
// なんでそうなるかの考察は不明
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	M := make(map[int]int)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		M[V]++
	}
	MM := make(map[int]int)
	for k, v := range M {
		if v >= 3 {
			if v%2 == 1 {
				MM[k] = 1
			} else {
				MM[k] = 2
			}
		} else {
			MM[k] = v
		}
	}
	count := 0
	for _, v := range MM {
		if v == 2 {
			count++
		}
	}
	if count%2 == 0 {
		fmt.Println(len(MM))
	} else {
		fmt.Println(len(MM) - 1)
	}
}


Measured memory_bytes: 10368