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

using namespace std;

int main()
{
	int K, S, X, A = 0;
	cin >> K >> S;

	if (K > S) {
		X = S;
		while (X >= 0) {
			
			A = A + (S - X + 1);
			--X;
		}
		
	}

	else if (2*K > S && S >= K) {
		X = K;
		while (X >= 0) {
			if (K < S - X) {
				A = A + (K - (S - X - K) + 1);
				X = X - 1;
			}

			else {
				A = A + S - X + 1;
				X = X - 1;
			}
			
		}
	}


	else if (3*K > S && S >= 2*K) {
		X = K;
		while (X >= 0) {
			if (S - X <=2*K) {
			A = A + (K - (S - X - K) + 1);
		}
		--X;
		}
	}

	else {A = 1;}

	cout << A << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


void solve(){
  ll A,B; cin >>A >>B;
  if (A > B) swap(A, B);
  // A <= B とする。
  /*
  f: 1 2 3 4 ... A-1 [A] A+1 A+2 ...
  s: 1 2 3 4 ... A-1  A  A+1 A+2 ... ... B-1 [B] B+1 B+2 ...

  a < b とすると a*b - (a-1)*(b+1) = b-a+1 > 1 より、
  (f, s) = (A-1)*(B+1), (A-2)*(B+2), ..., 1*(B+A-1) はいずれも A*Bより小さい。このA-1個は条件を満たす

  A == B ならこれの*2で終わりそう
  */
  ll res = A-1;
  if (A == B){
    res *= 2; cout <<res <<endl; return;
  }
 
  /*
  A < B とする。

  残りは
  f:                 [A] A+1 A+2 ... B-2 B-1 ...
  s: 1 2 3 4 ... A-1  A  A+1 A+2 ... B-2 B-1 [B]

  s: 1 2 ... A-1 はいけるだろうが、A A+1 ... B-2 はどうにかできないだろうか？
  ※ B-1 はどうあがいても (A+1)(B-1)-AB = B-A-1 >= 0 なのでOUT

  x*x < AB とするxが見つかったとすると

  */
  
  ll x = sqrt((double)A*B);
  if (x*(x+1) < A*B){
    res += x+1;
    res += x-1-A;
  }else if (x*x < A*B){
    res += x;
    res += x-1-A;
  }else {
    res += x-1;
    res += x-1-A;
  }
  cout <<res <<endl;
}

int main() {
  int Q; cin >>Q;
  rep(qq, Q) solve();
}

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

#define pb push_back
#define mp make_pair

long long arr[100010];

void solve()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> arr[i];

	int zero = 0;
	for (int i = 0; i < n; i++)
		if (arr[i] == 0)
			zero++;

	if (zero)
	{
		cout << "0";
		return;
	}

	long long prod = 1;
	for (int i = 0; i < n; i++)
	{
		if (arr[i] <= 1000000000000000000 / prod)
			prod *= arr[i];
		else
		{
			cout << "-1";
			return;
		}
	}
	cout << prod;

}


int main()
{

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

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

	int t = 1;
	// cin >> t;

	while (t--)
	{
		solve();
		cout << "\n";
	}

	return 0;
}

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

int main() {
	int  n ,k ,x ,y;
	cin >> n >> k >> x >> y;
	if (n > k) {
		cout << (k * x) + (n - k)*y << endl;
	}
	else {
		cout << n * x << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = list(map(int, input().split()))
min_min_h = 10**9+1
for i in range(101):
    for j in range(101):
        tmp = []
        tmp2 = []
        for k in range(N):
            if h[k] !=0:
                tmp.append(abs(i-x[k])+abs(j-y[k])+h[k])
            else:
                tmp2.append(abs(i-x[k])+abs(j-y[k]))
        if len(set(tmp)) == 1:
            for l in range(len(tmp2)):
                if tmp[0]>tmp2[l]:
                    break
            else:
                print(i,j,tmp[0])


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        double W = sc.nextInt();
        double H = sc.nextInt();
        double x = sc.nextInt();
        double y = sc.nextInt();
        
        int ans = (x == W/2 && y == H/2) ? 1 : 0;
        
        System.out.print(W * H / 2);
        System.out.print(" ");
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
a,b,c,k = map(int,input().split())

ans = 0
if(k>a):
    k-=a
    ans+=a
else:
    ans = k
    k=0
if k>0:
    if k>b:
        k-=b
    else:
        k=0
if k>0:
    if k>c:
        ans-=c
    else:
        ans -= k

print(ans)


Measured memory_bytes: 61760
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=3009;
int main()
{
    FASTINOUT;
    ll x;
    cin>>x;
    ll y[x];
    ll sum=0;
    map<ll,ll>m;
    for (int i=0;i<x;i++){
        cin>>y[i];
        m[y[i]]++;
        sum+=y[i];
    }
    int q;
    cin>>q;
    int l,r;
    while (q--){
        cin>>l>>r;
        if (m.find(l)!=m.end()){
            int z=m[l];
            int dif=r-l;
            sum=sum+dif*z;
            m.erase(l);
            m[r]+=z;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 8380
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n,m; cin>>n>>m;
	if(n==1 && m==1) cout<<1;
	else if(n==1) cout<<m-2;
	else if(m==1) cout<<n-2;
	else cout<<(n-2)*(m-2);
	
	return 0;
}

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

int main()
{
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;

  if (a <= 5)
    cout << 0 << "\n";
  else if (a >= 6 && a <= 12)
    cout << b / 2 << "\n";
  else
    cout << b << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip> 
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n,*p; string* str,s1;
    while (cin >> n)
    {
        int ans = 0,k=1;
        p = new int[n + 1]; str = new string[n];
        for (int i = 0; i < n; i++)
            cin >> str[i] >> p[i];
        cin >> s1;
        for (int i = 0; i < n; i++)
        {
            if (k == 0)
            {
                ans = ans + p[i];
            }
            if (str[i] == s1)
            {
                k = 0;
            }
            
        }
        cout << ans << '\n';
    }

    
}



Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())
ll ksm(ll a,ll b){ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

ll s[100005];
ll ans;

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll n,k;
	cin>>n>>k;
	for(ll i=k;i>=1;i--)
	{
		ll x=k/i;
		s[i]+=ksm(x,n);
		for(int j=i*2;j<=k;j+=i)
		{
			s[i]=(s[i]-s[j]+MOD)%MOD;
		}
		ans=(ans+s[i]*i%MOD)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int K, X;
	cin >> K >> X;
	for (int i = max(-1000000, X - K + 1); i <= min(1000000, X + K - 1); i++) {
		if (i != max(-1000000, X - K + 1)) cout << " ";
		cout << i;
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int aa = Integer.parseInt(s.substring(0, 2));
		int bb = Integer.parseInt(s.substring(2, 4));
		String ans;
		if (check(aa, bb)) {
			if (check(bb, aa)) {
				ans = "AMBIGUOUS";
			} else {
				ans = "YYMM";
			}
		} else {
			if (check(bb, aa)) {
				ans = "MMYY";
			} else {
				ans = "NA";
			}
		}
		System.out.println(ans);
	}
	
	static boolean check(int y, int m) {
		if (m >= 1 && m <= 12) {
			return true;
		} else {
			return false;
		}
	}
}


Measured memory_bytes: 21588
program abc135c
   implicit none
   integer(8) :: n, i, sum_attacker
   integer(8), allocatable :: a(:), b(:)

   read(*,*) n
   allocate(a(n+1), b(n))

   read(*,*) a(1:n+1)
   read(*,*) b(1:n) ! Brave

   sum_attacker = sum(a)

   do i = 1, n
      if (a(i)>=b(i)) then
         a(i) = a(i) - b(i)
         b(i) = 0
      else if (a(i) < b(i)) then
         b(i) = b(i) - a(i)
         a(i) = 0
         a(i+1) = max(a(i+1)-b(i), 0)
      end if
!      write(*,*) i, 'remain attacker:', a(:)
   end do

!   write(*,*) 'remain attacker:', a(:)

   write(*,*) sum_attacker - sum(a)
end program abc135c


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define One_for(i,n) for(int i=1;i<=n;++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=1;i<=b;++i)
#define int long long
static const int INF = 1<<25;
using namespace std;

int N,W;
int v[10010],w[10100];
int mem[110][10010];
int ans;
int dfs(int n,int h){
    if(mem[n][h]!=0)ans=mem[n][h];
    else if(n==0||h==0)ans=0;
    else if(h<w[n])ans=dfs(n-1,h);
    else ans=max(max(dfs(n-1,h),dfs(n-1,h-w[n])+v[n]),dfs(n,h-w[n])+v[n]);
    return mem[n][h]=ans;
}

signed main(){
    cin>>N>>W;
    One_for(i,N){
        cin>>v[i]>>w[i];
    }
    cout<<dfs(N,W)<<endl;
}

Measured memory_bytes: 9824
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	if (a > b)
	{
		swap(a, b);
	}

	string s;
	for (ll i = 0; i < b; i++)
	{
		s = s + to_string(a);
	}

	println(s);
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 3010

ll dp[SIZE][SIZE];
ll dpr[SIZE][SIZE];

int main(){
  int N, T, A[SIZE], B[SIZE];

  cin >> N >> T;

  for (int i=0; i<N; i++) {
    cin >> A[i] >> B[i];
  }

  for (int i=0; i<N; i++) {
    for (int j=0; j<T; j++) dp[i+1][j] = dp[i][j];
    for (int j=T-A[i]-1; j>=0; j--) {
      dp[i+1][j+A[i]] = max(dp[i+1][j+A[i]], dp[i][j] + B[i]);
    }
  }

  for (int i=N-1; i>=0; i--) {
    for (int j=0; j<T; j++) dpr[i][j] = dpr[i+1][j];
    for (int j=T-A[i]-1; j>=0; j--) {
      dpr[i][j+A[i]] = max(dpr[i][j+A[i]], dpr[i+1][j] + B[i]);
    }
  }

  for (int i=0; i<N; i++) {
    for (int j=0; j<=T; j++) {
      dp[i][j+1] = max(dp[i][j], dp[i][j+1]);
      dpr[i][j+1] = max(dpr[i][j], dpr[i][j+1]);
    }
  }

  ll ans = 0;

  for (int i=0; i<N; i++) {
    for (int j=0; j<T; j++) {
      ans = max(ans, dp[i][j] + dpr[i+1][T-j-1] + B[i]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 141568
n = int(input())
h = [int(i) for i in input().split()]

mx = [0] * n
mx[0] = h[0]
for i in range(1,n):
    mx[i] = max(mx[i-1], h[i])

mn = [0] * n
mn[0] = h[n-1]
for i in range(1,n):
    mn[i] = min(mn[i-1], h[n-1-i])

if all([mx[i]-mn[n-2-i]<=1 for i in range(n-1)]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
using namespace std;
char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
ll read(){
	char ch=gc();ll x=0;int op=1;
	for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 100005
int n,k,a[N],b[N],lb,la,ans;
int main(){
	n=read(),k=read();
	rep (i,1,n){
		int x=read();
		if (x>=0) b[++lb]=x;else a[++la]=-x;
	}
	sort(&a[1],&a[la+1]);sort(&b[1],&b[lb+1]);
	ans=inf;
	rep (i,0,lb){
		if (i>k) break;
		if (k-i>la) continue;
		// printf("%d %d\n",i,k-i);
		if (!i||!(k-i)) ans=min(ans,b[i]+a[k-i]);
		else{
			ans=min(ans,b[i]+a[k-i]+min(b[i],a[k-i]));
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

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

	int n, i;
	cin>>n;
	for(i=1000; i<=n; i+=1000){
		if(i>=n){
		break;
	}
	else
	continue;
	}
	cout<<abs(i-n);
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m,L,q;
vvl g;

int main(){
	cin>>n>>m>>L;
	g=vvl(n,vl(n,INF));
	for(int i=0;i<n;i++) g[i][i]=0;
	for(int i=0;i<m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		u--;v--;
		g[u][v]=g[v][u]=w;
	}
	for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(i!=j){
		if(g[i][j]<=L) g[i][j]=1;
		else g[i][j]=INF;
	}
	for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	cin>>q;
	for(int i=0;i<q;i++){
		int u,v;
		cin>>u>>v;
		int res=g[u-1][v-1];
		if(res==INF) res=0;
		cout<<res-1<<endl;
	}
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), k = in.nextInt();
			DisjointSet set = new DisjointSet(n);

			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt()-1;
			}

			for (int i = 0; i < k; i++) {
				int x = in.nextInt()-1, y = in.nextInt()-1;
				set.unite(x, y);
			}

			int count = 0;
			for (int i = 0; i < n; i++) {
				if (set.same(a[i], i)) {
					count++;
				}
			}

			out.println(count);

		}

		public class DisjointSet {

			int[] p, rank;

			public DisjointSet(int size) {
				p = new int[size];
				rank = new int[size];

				for (int j = 0; j < size; j++) {
					makeSet(j);
				}
			}

			private void makeSet(int x) {
				p[x] = x;
				rank[x] = 0;
			}

			public int findSet(int x) {
				return p[x] == x ? x : findSet(p[x]);
			}

			public void link(int x, int y) {
				if (rank[x] > rank[y]) {
					p[y] = x;
				} else if (rank[x] < rank[y]) {
					p[x] = y;
				} else if (rank[x] == rank[y]) {
					p[x] = y;
					rank[y]++;
				}
			}

			public void unite(int x, int y) {
				link(findSet(x), findSet(y));
			}

			public boolean same(int x, int y) {
				return findSet(x) == findSet(y);
			}
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 45568
#include<iostream>
#include<algorithm>
using namespace std;
int i, j, k;

int main (){
    int N;
    int a[200000];
    int b[200000];

    cin >> N;
    for(i=0; i<N; i++){
        cin >> a[i];
    }
    for(i=0; i<N; i++){
        cin >> b[i];
    }
    int ans = 0;
    for(i=28; i>=0; i--){
        for(j=0; j<N; j++){
            a[j] %= 1<<(i+1);
            b[j] %= 1<<(i+1);
        }
        sort(b, b+N);

        int bit = 0;
        int range_min[5];
        range_min[0] = 0;
        range_min[4] = N;
        for(j=0; j<N; j++){
            for(k=1; k<=3; k++){
                int ng = -1;
                int ok = N;
                while(ok-ng > 1){
                    int mid = (ok+ng)/2;
                    if(b[mid] + a[j] >= k<<i){
                        ok = mid;
                    }else{
                        ng = mid;
                    }
                }
                range_min[k] = ok;
            }
            bit ^= 1 & ((range_min[2]-range_min[1]) ^ (range_min[4]-range_min[3]));
        }
        ans += bit * (1<<i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    int n = ceil((-1 + sqrt(1 + 8*N)) / 2);
    int t = n*(n+1)/2 - N;
    for (int i = 1; i <= n; i++) if (i != t) cout << i << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
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; }

#include <iomanip>
int main() {
    int N; cin >> N;
    vector<double> p(N + 1);
    for (int i = 1; i <= N; i++) cin >> p[i];

    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int h = 0; h <= i; h++) {
            if (h) dp[i][h] += dp[i - 1][h - 1] * p[i];
            dp[i][h] += dp[i - 1][h] * (1 - p[i]);
        }
    }
    double res = 0.0;
    for (int h = 0; h <= N; h++) if (N - h < h) res += dp[N][h];
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

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

string S;

int main() {
    cin >> S;

    int NEWS[4];
    memset(NEWS, 0, sizeof(NEWS));

    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'N') NEWS[0]++;
        else if (S[i] == 'E') NEWS[1]++;
        else if (S[i] == 'W') NEWS[2]++;
        else NEWS[3]++;
    }

    bool f = false;
    if (NEWS[0] > 0 && NEWS[3] > 0 && NEWS[1] == 0 && NEWS[2] == 0) f = true;
    if (NEWS[0] == 0 && NEWS[3] == 0 && NEWS[1] > 0 && NEWS[2] > 0) f = true;
    if (NEWS[0] > 0 && NEWS[3] > 0 && NEWS[1] > 0 && NEWS[2] > 0) f = true;

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 384
#coding: utf-8

def com(a):
    return a**3

n,k = map(int,raw_input().split())

sho = n/k

if k%2 == 0:
    amari = n%k
    if amari >= (k>>1):
        print com(sho) + com(sho + 1)
    else:
        print com(sho) * 2
else:
    print com(sho)





Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,q,v[1<<18],w[1<<18],vv[20],ww[20];
int smv[1<<12],smw[1<<12];
struct st{int v,w;};basic_string<st> ans[1<<12];
bool operator<(st x,st y){return x.w<y.w||x.w==y.w&&x.v>y.v;}
void solve(int n,basic_string<st> &v){
	for(int i=0;i<(1<<n);i++){
		smv[i]=i?smv[i&i-1]+vv[__lg(i&-i)+1]:0;
		smw[i]=i?smw[i&i-1]+ww[__lg(i&-i)+1]:0;
		if(smw[i]<=1e5)v+={smv[i],smw[i]};
	}
	sort(v.begin(),v.end());
	int ls=0;
	for(st&x:v)x.v=ls=max(x.v,ls);
}
int qryV(int p,int L){
	return (upper_bound(ans[p].begin(),ans[p].end(),st{-1,L})-1)->v;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",v+i,w+i);
	for(int i=1;i<=min((1<<12)-1,n);i++){
		int _=0;
		for(int j=i;j;j/=2)vv[++_]=v[j],ww[_]=w[j];
		solve(_,ans[i]);
	}
	scanf("%d",&q);
	while(q--){
		int p,l;scanf("%d%d",&p,&l);
		if(p<(1<<12))printf("%d\n",qryV(p,l));else{
			int _=0,ans=0,j;
			for(j=p;j>=(1<<12);j/=2)vv[++_]=v[j],ww[_]=w[j];
			for(int i=0;i<(1<<_);i++){
				smv[i]=i?smv[i&i-1]+vv[__lg(i&-i)+1]:0;
				smw[i]=i?smw[i&i-1]+ww[__lg(i&-i)+1]:0;
				if(smw[i]<=l)ans=max(ans,qryV(j,l-smw[i])+smv[i]);
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 93144
a,b,c = map(int,input().split())
if a %2 == 1 or b %2 == 1 or c %2 == 1:
    print(0)
elif a == b and b == c and c == a:
    print(-1)
else:
    cnt = 0
    while(True):
        cnt += 1
        ta = b//2 + c //2
        tb = a//2 + c //2
        tc = a//2 + b //2
        if ta %2 == 1 or tb %2 == 1 or tc %2 == 1:
            break
        a,b,c = ta,tb,tc
    print(cnt)


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  vector<int> x(5);
  for (int &x : x) {
    cin >> x;
  }

  for (long i = 0; i < 5; i++) {
    if (x.at(i) == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}


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

 using namespace std;

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

 vector<int> A(N);
  for (int i = 0; i < N; ++i) {
 cin >> A[i];
 --A[i];
 }
 vector<int> B(N);
 for (int i = 0; i < N; ++i) {
 cin >> B[i];
 }
 vector<int> C(N-1);
 for (int i = 0; i < N; ++i) {
 cin >> C[i];
 }

 int ans = 0;
 for (int i = 0; i < N; ++i) {
 ans += B[A[i]];
 if (i > 0 && A[i] == A[i-1]+1) {
 ans += C[A[i-1]];
 }
 }

  cout<<ans;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,t,x,y,a,b,ans;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d%d%d",&t,&a,&b);
		if(abs(x-a)+abs(y-b)>t-ans||((abs(x-a)+abs(y-b))%2!=(t-ans)%2)){
			puts("No");
			return 0;
		}
		x=a,y=b,ans=t;
	}
	puts("Yes");
	return 0;
}

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

using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	ll n, ans = 0;
	cin >> n;
	for (ll i = 1; i <= n; i++) {
		ll a = n / i;	
		ans += (a * (a + 1) * i) / 2;
	}	
	cout << ans << "\n";
	return 0;
}


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

int main(){
  long long N,K;
  cin >> N >> K;
  vector<long long> A(N);
  int tmp;
  for(int i=0; i<N; i++){
    cin >> tmp;
    A[i] = tmp-1;
  }
  int i=0;
  long long count = 0;
  int flag=0;
  vector<long long> che(N,-1);
  while(!flag){
    che[i] = count;
    i = A[i];
    count++;
    if(count == K){flag=1;}
    else if(che[i] != -1){flag=2;}
  }
  long long freq;
  if(flag == 1) cout << i+1;
  else{
    freq = count - che[i];
    int S = (K-che[i])%freq;
    for(int j=0; j<S; j++){
      i = A[i];
    }
    cout << i+1;
  }
  return 0;
}

Measured memory_bytes: 6436
#juppy's code for testing run time only. 
def main():
    import sys
    input = sys.stdin.readline
    n,m,l = map(int,input().split())
    d = [[10**12]*n for _ in [0]*n]
    for i in range(m):
        a,b,c = map(int,input().split())
        if l >= c:
            d[a-1][b-1] = d[b-1][a-1] = c
    for i in range(n):
        d[i][i] = 0
 
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
 
    edge = [[10**12]*n for _ in [0]*n]
    for i in range(n):
        for j in range(n):
            if d[i][j] <= l:
                edge[i][j] = 1
 
    for k in range(n):
        for i in range(n):
            for j in range(n):
                edge[i][j] = min(edge[i][j],edge[i][k] + edge[k][j])
 
    q = int(input())
    for _ in [0]*q:
        s,t = map(int,input().split())
        if edge[s-1][t-1] >= 10**12:
            print(-1)
        else:
            print(edge[s-1][t-1]-1)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 56156
import math
def resolve():
    N, H = list(map(int, input().split()))
    attacks = []
    for i in range(N):
        a, b = list(map(int, input().split()))
        attacks.append((a, 0))
        attacks.append((b, 1))
    attacks = sorted(attacks)
    damage = 0
    cnt = 0
    while damage < H:
        dam, once = attacks.pop()
        damage += dam
        cnt += 1
        if not once:
            cnt += math.ceil((H - damage) / dam)
            break
    print(cnt)



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 26044
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i=0; i<N; i++) cin >> H[i];
  
  int cnt = 0;
  int ans = H[0];
  for (int i=0; i<N; i++) {
    if (ans <= H[i]) cnt++;
    ans = max(ans,H[i]);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    private static void solver(InputReader sc, PrintWriter out) {
        int row = sc.nextInt();
        int col = sc.nextInt();
        char arr[][] = new char[row][col];
        long dp[][] = new long[row][col];
        dp[0][0] = 1;
        for(int i=0; i<row; i++){
            String s = sc.next();
            arr[i] = s.toCharArray();
        }
        int mod = (int)1e9+7;
        for(int i=0; i<row; i++){
            for(int j=0; j<col; j++){
                if(arr[i][j] == '#' || i==0  && j==0) continue;
                if(i-1 < 0) dp[i][j] = dp[i][j-1];
                else if(j-1 < 0) dp[i][j] = dp[i-1][j];
                else {
                    dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                    dp[i][j] %=mod;
                }
            }
        }
        out.println(dp[row-1][col-1]);

    }
    public static long lcm(long x, long y){
        return x / gcd(x,y) * y;
    }
    public static long gcd(long a, long b){
        if(b==0) return a;
        else return gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
class Pair {
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

Measured memory_bytes: 37656
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val result = Array.ofDim[Int](n, n)
  (0 until n).foreach { _ =>
    val a = StdIn.readLine().split(' ').map(_.toInt)
    (0 until a(1)).foreach { k =>
      result(a(0) - 1)(a(2 + k) - 1) = 1
    }
  }
  
  //(0 until n).foreach(i => println((i+1) + ": " +result(i).mkString(" ")))
  val edges = Array.ofDim[Int](n) // 0: ini, 1: current, 9: finish
  val timeS = Array.ofDim[Int](n)
  val timeE = Array.ofDim[Int](n)
  var time = 0

  private val WHITE = 0
  private val GRAY = 1
  private val BLACK = 9

  def depthFirstSearch(u: Int): Unit = {
    edges(u) = GRAY
    time += 1
    timeS(u) = time
    (0 until n).foreach { v =>
      if(result(u)(v) == 1 && edges(v) == WHITE){
        depthFirstSearch(v)
      }
    }
    edges(u) = BLACK
    time += 1
    timeE(u) = time
  }

  (0 until n).foreach( v => if(edges(v) == WHITE)depthFirstSearch(v))
  val r = (0 until n).map(v => s"${v+1} ${timeS(v)} ${timeE(v)}")
  
  println(r.mkString(f"%n"))
  
}



Measured memory_bytes: 44212
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, d, i, j, k;
	cin >> n >> d;
	vector <vector <int> > v(n, vector <int> (d, 0));
	fo(i, 0, n){
		fo(j, 0, d)
		cin >> v[i][j];
	}
	int ans = 0;
	fo(i, 0, n){
		fo(j, i + 1, n){
			double res = 0;
			fo(k, 0, d)
			res += ((ld)v[i][k] - (ld)v[j][k]) * ((ld)v[i][k] - (ld)v[j][k]);
			int x = (int)sqrt(res);
			ans += (x == sqrt(res));
		}
	}
	cout << ans;
}

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

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

  bool flag = true;
  for (int i = 0; i < s.size(); i += 2) {
    if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
    }
    else {
      flag = false;
      break;
    }
  }
  for (int i = 1; i < s.size(); i += 2) {
    if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
    }
    else {
      flag = false;
      break;
    }
  }

  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n, x, t;
    cin >> n >> x >> t;
    int u = n / x;
    if (n % x)
    {
        u += 1;
    }
    lli a = u * t;
    cout << a << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> v(n), s(n+1, 0), s2(n+1, 0);
    for (auto &&i : v) scanf("%lld", &i);
    for (int i = 0; i < n; ++i) {
        if(i == 0) s2[1] = v[i];
        else s2[i+1] = s2[i-1] + v[i];
        s[i+1] = s[i]+v[i];
    }
    for (int i = 0; i < q; ++i) {
        int X;
        scanf("%d", &X);
        int low = 0, high = n;
        while(high-low > 1){
            int mid = (low+high)/2;
            if(v[mid-1] < X) low = mid;
            else {
                int tak = n-mid;
                int ao = mid - (lower_bound(v.begin(), v.end(), max(1LL, 2*X-v[mid-1]))- v.begin());
                (tak < ao ? high : low) = mid;
            }
        }
        ll ans = s[n]-s[low];
        if(2*low >= n) ans += s2[2*low-n];
        printf("%lld\n", ans);
    }
    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005, mod = 1000000007;
int n, m, dp[MX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	while (m--) {
		int a;
		cin >> a;
		dp[a] = -1;
	}

	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		if (dp[i] == -1) continue;
		dp[i] %= mod;
		if (dp[i+1] != -1) dp[i+1] += dp[i];
		if (dp[i+2] != -1) dp[i+2] += dp[i];
	}
	cout << dp[n] % mod << endl;

	return 0;
}


Measured memory_bytes: 640
using System;
using System.Text;

public class A
{
	public static void Main()
	{
		StringBuilder sb = new StringBuilder(Console.ReadLine());
		sb.Replace("eraser", "");
		sb.Replace("erase", "");
		sb.Replace("dreamer", "");
		sb.Replace("dream", "");
		if(sb.ToString() != "")
		{
			Console.WriteLine("NO");
		}
		else
		{
			Console.WriteLine("YES");
		}
	}
}

Measured memory_bytes: 13096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int n;
int a[200005];
int nax1 = -1, nax2 = -2;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  
  for(int i = 1; i <= n; i++) {
    if(nax1 < a[i]) {
      nax2 = nax1;
      nax1 = a[i];
    } else if(nax2 < a[i]) {
      nax2 = a[i];
    }
  }
  for(int i = 1; i <= n; i++) {
    if(a[i] == nax1) cout << nax2 << endl;
    else cout << nax1 << endl;
  }
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<(char)(s1[0]-'a'+'A')<<(char)(s2[0]-'a'+'A')<<(char)(toupper(s3[0]))<<endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;



int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    string s; cin>>s;
    int n = s.size();
    map<char, int> mp;
    for(int i =0; i<n; i++)mp[s[i]]++;
    for(int i =0; i<n; i++){
        if(isOdd(mp[s[i]]))
            return cout<<"No", 0;
    }
    cout<<"Yes";
	return 0;

}


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

int main() {
	
 map<int,int>a;
  
  int n,tmp;
  cin >> n;
  for(int i = 0; i < n;i++){
    cin >> tmp;
    a[tmp] = 1;
  }
  cout << a.size();
}


Measured memory_bytes: 256
from math import ceil
S = input()
Result = [0] * len(S)
S += "R"

num_R = 0
num_L = 0
past_bottom_pointer = 0

for pointer in range(len(S) - 1):
    left = S[pointer]
    right = S[pointer + 1]

    if left == "R" and right == "R":
        #down
        num_R += 1

    elif left == "R" and right == "L":
        #bottom
        num_R += 1
        #print(num_R, num_L)
        Result[pointer] += ceil(num_R / 2)
        Result[pointer + 1] += num_R // 2
        num_R = 0
        past_bottom_pointer = pointer

    elif left == "L" and right == "L":
        #up
        num_L += 1

    elif left == "L" and right == "R":
        #top
        num_L += 1
        #print(num_R, num_L)
        Result[past_bottom_pointer] += num_L // 2
        Result[past_bottom_pointer + 1] += ceil(num_L / 2)
        num_L = 0

    #print(pointer, Result)

print(*Result)

Measured memory_bytes: 54604
#b
s = input()

def judge(seq):
    flag = True
    group = ['A', 'T', 'G', 'C']
    for s in seq:
        if s not in group:
            flag = False
    return flag

max_len = 0
for x in range(len(s)):
    for y in range(x+1, len(s)+1):
        sub_seq = s[x:y]
        # print(sub_seq)
        if judge(s[x:y]):
            max_len = max(max_len, len(s[x:y]))

print(max_len)
        

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int x, y;
        Scanner sc = new Scanner(System.in);

        x = sc.nextInt();
        y = sc.nextInt();

        while (x % y != 0) {
            x%=y;
            int tmp = y;
            y = x;
            x = tmp;
        }
        System.out.println(y);
    }
}



Measured memory_bytes: 26128
H,W=map(int,input().split())
ans=min((H%3>0)*W,(W%3>0)*H)
A=[0]*3
A[0]=H//3*W
A[1]=(H-H//3)*(W//2)
A[2]=H*W-A[0]-A[1]
A.sort()
ans=min(ans,A[2]-A[0])
A[0]=(H//3+1)*W
A[1]=(H-H//3-1)*(W//2)
A[2]=H*W-A[0]-A[1]
A.sort()
ans=min(ans,A[2]-A[0])
H,W=W,H
A[0]=H//3*W
A[1]=(H-H//3)*(W//2)
A[2]=H*W-A[0]-A[1]
A.sort()
ans=min(ans,A[2]-A[0])
A[0]=(H//3+1)*W
A[1]=(H-H//3-1)*(W//2)
A[2]=H*W-A[0]-A[1]
A.sort()
ans=min(ans,A[2]-A[0])
print(ans)

Measured memory_bytes: 3064
a = ['A', 'G', 'C', 'T']
l = ["GACA","GACC","GACT","AGGC","AGCA","AGCG","AGCC","AGCT","AGTC","ACGA","ACGG","ACGC","ACGT","ATGC"]
dict1_y = {}
dict1_n = {}
dict2_y = {}
dict2_n = {}
t = 3
p = 10**9+7
n = int(input())
for i in a:
    for j in a:
        for k in a:
            s = i + j + k
            dict1_y[s] = 0
            dict1_n[s] = 0
            dict2_y[s] = 0
            dict2_n[s] = 0
for i in a:
    for j in a:
        for k in a:
            s = i + j + k
            if 'AGC' in s:
                dict1_y[s] += 1
            else:
                tem1 = s[0]
                tem2 = s[1]
                new_s = tem2 + tem1 + s[2]
                if 'AGC' in new_s:
                    dict1_y[s] += 1
                else:
                    tem1 = s[1]
                    tem2 = s[2]
                    new_s = s[0] + tem2 + tem1
                    if 'AGC' in new_s:
                        dict1_y[s] += 1
                    else:
                        dict1_n[s] += 1
while t != n:
    for k,v in dict1_y.items():
        for m in a:
            key = m + k[0] + k[1]
            dict2_y[key] += v
    for k,v in dict1_n.items():
        for m in a:
            new_s = m + k
            key = m + k[0] + k[1]
            if new_s in l:
                dict2_y[key] += v
            else:
                dict2_n[key] += v
    for i in a:
        for j in a:
            for k in a:
                s = i + j + k
                dict1_y[s] = dict2_y[s] % p
                dict1_n[s] = dict2_n[s] % p
                dict2_y[s] = 0
                dict2_n[s] = 0
    t += 1
ans = 0
for v in dict1_y.values():
    ans += v % p
print((4**n - ans) % p)



Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
#define N 200010
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,head[N],cnt,siz[N];
ll dp[N],fac[N],inv[N],g[N],ans[N];
struct Edge{
	int to,nxt;
}edge[N<<1];
void add(int a,int b){
	++cnt;
	edge[cnt].to=b;
	edge[cnt].nxt=head[a];
	head[a]=cnt;
}
ll C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
void dfs1(int u,int fa){
	int tot=0;
	dp[u]=siz[u]=1;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v==fa)continue;
		dfs1(v,u);
		siz[u]+=siz[v];
		dp[u]=dp[u]*dp[v]%mod;
	}
	tot=siz[u]-1;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v==fa)continue;
		dp[u]=dp[u]*C(tot,siz[v])%mod;
		tot-=siz[v];
	}
}
ll qpow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=fac[i-1]*i%mod;
	}
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
void dfs2(int u,int fa){
	if(u^1){
		//cout<<u<<" "<<dp[u]<<" "<<g[fa]<<" "<<n-siz[u]-1<<" "<<siz[u]<<endl;
		ans[u]=dp[u]*g[u]%mod*C(n-1,n-siz[u])%mod;
	}
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v==fa)continue;
		g[v]=ans[u]*qpow(dp[v]*C(n-1,siz[v])%mod,mod-2)%mod;
		dfs2(v,u);
	}
}
int main(){
	n=read();
	for(int i=1;i<n;++i){
		int u=read(),v=read();
		add(u,v),add(v,u);
	}
	init(n);
	dfs1(1,0);
	ans[1]=g[1]=dp[1];
	dfs2(1,0);
	for(int i=1;i<=n;++i){
		printf("%lld\n",ans[i]);
	}
	
	return 0;
}


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    string s;
    ci >> s;

    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) co << "Bad" << en;
    else co << "Good" << en;
  
    return 0;
}


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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<string>> table(h,vector<string> (w));
    int tableone = 65;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> table[i][j];
            if(table[i][j] == "snuke")
           {    
               tableone += j;
               char ans = char(tableone);
                cout << ans << i + 1 << endl;
            }
        }
    }
}

Measured memory_bytes: 256