akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;

int main() {
 int64_t A,B,K;
 cin>>A>>B>>K;
 int64_t AA=A;
 if(A<=K){A=0;B=max((int64_t)0,B-(K-AA));}
 else{A-=K;}
 cout<<A<<" "<<B<<endl;
 return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,k,a[100005];
int fac[100005],ifac[100005];
int ans1,ans2;

int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=1ll*res*x%mod;
		x=1ll*x*x%mod,y/=2;
	}
	return res;
}

int C(int x,int y){
	int res=1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
	return res;
}

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) if(a[i]<0) a[i]+=mod;
	fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=ksm(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	for(int i=k;i<=n;i++){
		ans1+=1ll*a[i]*C(i-1,k-1)%mod;
		if(ans1>=mod) ans1-=mod;
	}
	for(int i=1;i<=n-k+1;i++){
		ans2+=1ll*a[i]*C(n-i,k-1)%mod;
		if(ans2>=mod) ans2-=mod;
	}
	printf("%d\n",(ans1-ans2+mod)%mod);

	return 0; 
}

Measured memory_bytes: 1408
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
    for j in range(V+1):
        if j-v>=0 and dp[i-1][j-v]+w<=W:
            dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
        dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))


Measured memory_bytes: 314920
n = int(input())
p = list(map(int, input().split()))

c = 0
for i in range(n - 2):
  if not p[i+1] == max([p[i], p[i+1], p[i+2]]) and not p[i+1] == min([p[i], p[i+1], p[i+2]]):
    c += 1
print(c)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define int long long
#define INF (1LL<<60)
#define _1 first
#define _2 second
typedef pair<int, int> P;

int R, C, N;
vector<P> G[100000], B[100000];
int T[100000], M[100000];
vector<int> X;

bool g(int x) {
  X.push_back(x);
  for (auto &p : B[x]) {
    int u = p._1, v = T[x] + p._2;
    if (T[u] != INF && T[u] != v) return false;
    if (T[u] == INF) {
      T[u] = v;
      if (!g(u)) return false;
    }
  }
  return true;
}

bool f() {
  for (int y=0; y<R; y++) {
    sort(G[y].begin(), G[y].end());
    for (int i=1; i<G[y].size(); i++) {
      P &a = G[y][i-1], &b = G[y][i];
      B[a._1].push_back(P(b._1, b._2-a._2));
      B[b._1].push_back(P(a._1, a._2-b._2));
    }
  }
  for (int x=0; x<C; x++) T[x] = INF;
  for (int y=0; y<R; y++) {
    for (auto &p : G[y]) {
      int x = p._1;
      if (T[x] == INF) {
        X.clear();
        T[x] = 0;
        if (!g(x)) return false;
        int ma = INF, mb = INF;
        for (auto x : X) {
          mb = min(mb, T[x]);
          ma = min(ma, M[x] - T[x]);
        }
        if (ma+mb < 0) return false;
      }
    }
  }
  return true;
}

signed main() {
  cin >> R >> C >> N;
  for (int i=0; i<C; i++) M[i] = INF;
  for (int i=0; i<N; i++) {
    int r, c, a;
    cin >> r >> c >> a;
    r--, c--;
    G[r].push_back(P(c, a));
    M[c] = min(M[c], a);
  }
  if (f()) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 14456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int m = 0;
  for (int i = 0; i < 3; i++){
    if (s.at(i) == '1'){
      m++;
    }
  }
  cout << m << endl;    
}


Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
c = 0
bmax = N // B
for i in range(bmax+1):
  gmax = (N - B * i) // G
  for j in range(gmax+1):
    if (N - G * j - B * i) % R == 0:
      c += 1
print(c)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main() {
char c, o, f1, f2, e1, e2;

cin >> c >> o >> f1 >> f2 >> e1 >> e2;

if (f1 == f2 && e1 == e2)
  cout << "Yes";
else
  cout  << "No";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int s;
	int n;
	scanf("%d %d",&s,&n);
	
	if(n % 2 == 0 && (n >= 2*s && n <= 4*s)){
	    printf("Yes");
	}
	else{
		printf("No");
	}
}
			

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int dp[3001][3001]={0};
int main(void){
	string s,t,d;
	int i,j;
	cin>>s>>t;
	for(i=0;i<s.size();i++){
		for(j=0;j<t.size();j++){
			if(s[i]==t[j])	dp[i+1][j+1]=dp[i][j]+1;
			else			dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
		}
	}
	/* for(i=0;i<=s.size();i++){
		for(j=0;j<=t.size();j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	} */
	i=s.size()-1;	j=t.size()-1;
	d="";
	while(i>=0&&j>=0){
		/* cout<<s[i]<<" "<<t[j]<<endl;
		cout<<i<<" "<<j<<endl; */
		if(s[i]==t[j]){
			d+=t[j];
			i--;
			j--;
		}
		else{
			if(dp[i+1][j]>dp[i][j+1]){
				j--;
			}
			else{
				i--;
			}
		}
	}
	reverse(d.begin(),d.end());
	cout<<d<<endl;			
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	cout << (N == 0 ? 1 : 0) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 50;

int h, w, m, co[3][N][N], r, c, pr, pc, t;
char da[N][N];
vector<int> ti[N][N];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};
bool vis[N][N];

int move(int y, int x, int cnt){
  if(y == r && x == c) return cnt;
  vis[y][x] = true;
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
    if(da[ny][nx] == '#') continue;
    if(vis[ny][nx]) continue;
    int res = move(ny, nx, cnt+1);
    if(res >= 0){
      ti[y][x].push_back(t + cnt);
      return res;
    }
  }
  return -1;
}

main(){
  cin >> h >> w >> m;
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> da[i][j];
  for(int k=0;k<3;k++) for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> co[k][i][j];
  pr = -1;
  t = 0;
  for(int i=0;i<m;i++){
    cin >> r >> c;
    fill(vis[0], vis[N], false);
    if(pr != -1) t += move(pr, pc, 0);
    pr = r;
    pc = c;
    if(i + 1 == m) ti[r][c].push_back(t);
  }
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<ti[i][j].size();k++){
        if(k > 0 && co[1][i][j] + co[2][i][j] > co[0][i][j] * (ti[i][j][k] - ti[i][j][k-1]))
          ans += co[0][i][j] * (ti[i][j][k] - ti[i][j][k-1]);
        else ans += co[1][i][j] + co[2][i][j];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6552
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[][] Bingo = new int[3][3];
		//列
		//行
		//3*3の２次元配列宣言
		for(int i = 0 ; i < 3; i++) {
			for(int j = 0 ; j < 3; j++) {
				Bingo[i][j] = sc.nextInt();
			}
		}

		//当選番号入力数分回す
		int Count = sc.nextInt();
		int[] win = new int[Count];
		for(int c = 0; c <Count; c++) {
			win[c] = sc.nextInt();
		}

		//ビンゴ内に当選番号があるか比較しビンゴしているかを判断。
		for(int cnt = 0; cnt < win.length; cnt++) {
			for(int i = 0 ; i < 3; i++) {
				for(int j = 0 ; j < 3; j++) {
					if(Bingo[i][j] == win[cnt]) {
						Bingo[i][j] = 0;
					}
				}
			}
		}
		//ビンゴ全パターン
		boolean pattern1 = Bingo[0][0] + Bingo[0][1] + Bingo[0][2] == 0;
		boolean pattern2 = Bingo[1][0] + Bingo[1][1] + Bingo[1][2] == 0;
		boolean pattern3 = Bingo[2][0] + Bingo[2][1] + Bingo[2][2] == 0;
		boolean pattern4 = Bingo[0][0] + Bingo[1][1] + Bingo[2][2] == 0;
		boolean pattern5 = Bingo[2][0] + Bingo[1][1] + Bingo[0][2] == 0;
		boolean pattern6 = Bingo[0][0] + Bingo[1][0] + Bingo[2][0] == 0;
		boolean pattern7 = Bingo[0][1] + Bingo[1][1] + Bingo[2][1] == 0;
		boolean pattern8 = Bingo[0][2] + Bingo[1][2] + Bingo[2][2] == 0;

		//上記の条件のどれかがtrueが返されていたらYesを表示、それ以外はNoを返す
		if(pattern1 || pattern2 || pattern3 || pattern4 || pattern5 || pattern6 ||  pattern7 || pattern8) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    int c=0,s=0;
    getline(cin,a);
    for(int i=0;i<a.size();i++){
        if(a[i]=='p'){
            s--;
        }
    }
    s+=a.size()/2;
    cout<<s;
    return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;

int main(){
    
    int H,W,N;cin>>H>>W>>N;
    int s,t;cin>>s>>t;
    string S,T;cin>>S>>T;
    vector<int> U(N),D(N),L(N),R(N);
    bool flag=true;
    int u=0,d=0,l=0,r=0;
    for(int i=N-1;i>=0;i--){
        if(i!=N-1){
            if(T[i]=='U') d--;
            if(T[i]=='D') u--;
            d=max(d,0);
            u=max(u,0);
        }
        if(S[i]=='U') u++;
        if(S[i]=='D') d++;
        U[i]=u;
        D[i]=d;
    }
    if(U[0]>=s||(H-s+1)<=D[0]) flag=false;
    for(int i=1;i<N;i++){
        if(U[i]+D[i]>H) flag=false;
        if(U[i]==H||D[i]==H) flag=false;
    }
    
    for(int i=N-1;i>=0;i--){
        if(i!=N-1){
            if(T[i]=='L') r--;
            if(T[i]=='R') l--;
            r=max(r,0);
            l=max(l,0);
        }
        if(S[i]=='L') l++;
        if(S[i]=='R') r++;
        L[i]=l;
        R[i]=r;
    }
    if(L[0]>=t||(W-t+1)<=R[0]) flag=false;
    for(int i=1;i<N;i++){
        if(L[i]+R[i]>W) flag=false;
        if(L[i]==W||R[i]==W) flag=false;
    }
    
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    /*for(int i=0;i<N;i++){
        cout<<U[i]<<" "<<D[i]<<" "<<L[i]<<" "<<R[i]<<endl;
    }*/
}


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

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t;
	t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

void solve() {
	int x, a;
	cin >> x >> a;
	if (x < a) cout << 0;
	else cout << 10;
}	
 	

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll x, ans = 0, sum = 0;
    for (ll i = 0; i < n; i++) {
        cin >> x;
        a[i] = x - i - 1;
    }
    sort(a.begin(), a.end());
    ll mid = (n % 2 ? a[n / 2] : a[n / 2 - 1]);
    for (ll i = 0; i < n; i++) {
        ans += abs(a[i] - mid);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
char a[102][102];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='.') a[i][j]='0';
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='#')
			{
				if(a[i-1][j-1]!='#') a[i-1][j-1]++;
				if(a[i-1][j]!='#') a[i-1][j]++;
				if(a[i-1][j+1]!='#') a[i-1][j+1]++;
				if(a[i][j-1]!='#') a[i][j-1]++;
				if(a[i][j+1]!='#') a[i][j+1]++;
				if(a[i+1][j-1]!='#') a[i+1][j-1]++;
				if(a[i+1][j]!='#') a[i+1][j]++;
				if(a[i+1][j+1]!='#') a[i+1][j+1]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) cout<<a[i][j];
		cout<<endl;
	}
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

signed main(){
	int n,m;
	cin>>n>>m;
	int a[110000];
	rep(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	int lc=1;
	int memo=-1;
	rep(i,n){
		int t=a[i];
		int c=0;
		while(t%2==0){
			t/=2;
			c++;
		}
		if(memo==-1)memo=c;
		else if(memo!=c){
			cout<<0<<endl;
			return 0;
		}
		lc=lcm(lc,a[i]);
		if(lc>2*m){
			cout<<0<<endl;
			return 0;
		}
	}
	int mk=(m-a[n-1]/2)/a[n-1];
	int ms=(mk*2+1)*a[n-1];
	ans=(ms-lc)/(lc*2)+1;
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i).sort
b = []
m.times do |i|
  b[i] = gets.chomp.split.map(&:to_i).reverse
end
b.sort!.reverse!
i = 0
b.each do |bb|
  bb[1].times do
    if i < n && a[i] < bb[0]
      a[i] = bb[0]
    else
      puts a.inject(:+)
      exit
    end
    i += 1
  end
end
puts a.inject(:+)


Measured memory_bytes: 19832
#include<stdio.h>
int main(){
  int n,k,q,a[100001],i,b;
  scanf("%d%d%d",&n,&k,&q);
  for(i=0; i<n; i++){
    a[i]=0;
  }
  for(i=0; i<q; i++){
    scanf("%d",&b);
    a[b-1]++;
  }
  for(i=0; i<n; i++){
    if(k>q-a[i]){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }
  return 0;

}


Measured memory_bytes: 896
#include <stdio.h>

void right_triangle(int, int, int);

int main(){
	int N, a, b, c, i;
	scanf("%d", &N);
	for(i=0; i<N; ++i){
		scanf("%d %d %d", &a, &b, &c);
		right_triangle(a, b, c);
	}
	return 0;
}

void right_triangle(int x, int y, int z){
	int tmp;
	if(x > z){				//sort
		tmp = z;
		z = x;
		x = tmp;
	}
	if(y > z){
		tmp = z;
		z = y;
		y = tmp;
	}

	if(z*z == x*x+y*y){			
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}

Measured memory_bytes: 580
#include <stdio.h>
#include <string.h>

int main(){
	char arr1[101];
	char arr2[101];
	char arr3[101];
	
	scanf ("%s %s %s", &arr1, &arr2, &arr3);
		if (arr1[(strlen(arr1)-1)] == arr2[0] && arr2[(strlen(arr2)-1)] == arr3[0]){
			printf ("YES");
		}
		else {
			printf ("NO");
		}
	return 0;
}

Measured memory_bytes: 1652
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>

using namespace std;


int main(int argc, char* argv[]){
  long long int n,k;
  scanf("%lld%lld", &n,&k);
  long long int ans = 0;
  long long int bn;
  //long long int cn;
  long long int maxk=0;
  while(maxk<=n){
    maxk+=k;
  }
  maxk-=k;
  for(int i=1;i<=n;i++){
      if(((i%k)*2)%k==0){
        bn=n/k;
        if(maxk+(i%k)<=n && i%k != 0)bn++;
        bn=bn*bn;
        //cn=n/k;
        ans += bn;
      }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.count()/1e6 << endl;
*/
void solve(){
    string s,t;
    cin>>s>>t;
    if(s.length()+1!=t.length()){
        cout<<"No";
        return;
    }
    fr(i,0,s.length()){
        if(s[i]!=t[i]){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e12;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    for(int i=0; i<S.size(); i++){
        if(S[i] == '?'){
            S[i] = 'D';
        }
    }
    cout << S << "\n";
    return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  int a[m], b[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    mp[a[i]]++;
    mp[b[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//AtCoder ABC069 C - 4-adjacent
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    vector<ll> an(N,0);
    for(auto&& a:an){
        cin>>a;
    }
    //
    ll four_bai=0;
    ll two_bai=0;
    ll dis=0;
    for(const auto& a:an){
        if(a%4==0){
            ++four_bai;
        } else if(a%2==0){
            ++two_bai;
        } else {
            ++dis;
        }
    }
    bool ans=false;
    ans |= (four_bai>=dis);
    ans |= (two_bai==0&&four_bai+1>=dis);
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

#include <iostream>

int main()
{
	string n; cin >> n;
	string m="";

	rep(i, 3) {
		if (n[i] == '1') { m += "9"; }
		else if (n[i] == '9') { m += "1"; }
	}

	cout << m << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc140/tasks/abc140_d
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; ++i)

#define REPR(i, n) for (int i = n; i >= 0; --i)

#define REP_(i, m, n) for (int i = m; i < n; ++i)

#define INF 2e9

using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    int cnt = 0;
    REP_(i, 1, n - 1)
    {
        if (s[i] != s[i + 1] && s[i] == 'R')
            cnt++;
        if (s[i] != s[i - 1] && s[i] == 'L')
            cnt++;
    }

    if (s[0] == 'L' || s[0] != s[1])
        cnt++;
    if (s[n - 1] == 'R' || s[n - 1] != s[n - 2])
        cnt++;

    if (cnt <= k * 2)
    {
            cout << n - 1 << endl;
    }
    else
    {
        cout << n - (cnt - 2 * k) << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;
int val[5][5];
bool mark[5][5];
set<int> num;
int main()
{
    for(int i=1;i<=3;i++)
        for(int j=1;j<=3;j++)
            scanf("%d",&val[i][j]);
    int n;
    scanf("%d",&n);
    num.clear();
    while(n--)
    {
        int a;
        scanf("%d",&a);
        num.insert(a);
    }
    memset(mark,0,sizeof(mark));
    for(int i=1;i<=3;i++)
        for(int j=1;j<=3;j++)
            mark[i][j]=(bool)num.count(val[i][j]);
    bool ans=false;
    for(int i=1;i<=3;i++)
    {
        bool row=true;
        for(int j=1;j<=3;j++)
            row&=mark[i][j];
        ans|=row;
        bool col=true;
        for(int j=1;j<=3;j++)
            col&=mark[j][i];
        ans|=col;
    }
    ans|=(mark[1][1]&&mark[2][2]&&mark[3][3]);
    ans|=(mark[1][3]&&mark[2][2]&&mark[3][1]);
    puts(ans?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {

            var card = new bool[4, 13];

            for (var i = 0; i < 4;i++ )
            {
                for(var r=0;r<13;r++)
                {
                    card[i, r] = false;
                }
            }

            var read = Console.ReadLine();
            int num = int.Parse(read);


                for (int i = 0; i < num; i++)
                {
                    read = Console.ReadLine();
                    var temp_string = read.Split(' ');

                    switch (temp_string[0])
                    {
                        case "S":
                            {
                                card[0, int.Parse(temp_string[1])-1] = true;
                                break;
                            }
                        case "H":
                            {
                                card[1, int.Parse(temp_string[1])-1] = true;
                                break;
                            }
                        case"C":
                            {
                                card[2, int.Parse(temp_string[1])-1] = true;
                                break;
                            }
                        case"D":
                            {
                                card[3, int.Parse(temp_string[1])-1] = true;
                                break;
                            }
                    }

                }

                for (var i = 0; i < 4; i++)
                {
                    for (var r = 0; r < 13; r++)
                    {
                        if(!(card[i,r]))
                        {
                            switch(i)
                            {
                                case 0:
                                    {
                                        Console.WriteLine("S " + (r+1));
                                        break;
                                    }

                                case 1:
                                    {
                                        Console.WriteLine("H " + (r+1));
                                        break;
                                    }

                                case 2:
                                    {
                                        Console.WriteLine("C " + (r+1));
                                        break;
                                    }

                                case 3:
                                    {
                                        Console.WriteLine("D " + (r+1));
                                        break;
                                    }
                            }
                        }
                    }
                }
        }
    }
}

Measured memory_bytes: 9224
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Multiplication 1
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d\n", a * b);
  return 0;
}


Measured memory_bytes: 3224
package main
import . "fmt"
func main() {
  var n,d int
  var m map[int]struct{}
  Scan(&n)
  m = make(map[int]struct{},n)
  for i:=0;i<n;i++ {
    Scan(&d)
    m[d] = struct{}{}
  }
  Println(len(m))
}

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

using namespace std;

using ll = long long;

int main() {
    std::string S;
    ll K;

    cin >> S >> K;

    ll num_one = 0;
    char c = '1';
    for (ll i = 0; i < S.size(); ++i) {
        if (S[i] == '1') {
            ++num_one;
        } else {
            c = S[i];
            break;
        }
    }

    cout << (num_one >= K ? '1' : c) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    ll h,w;
    ll mod = 1e9 + 7;
    cin>>h>>w;
    char arr[h+1][w+1];
    ll dp[h+1][w+1];
    
    for(ll i=0;i<=h;i++)
        dp[i][0] = 0;
    for(ll i=0;i<=w;i++)
        dp[0][i] = 0;
    
    
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++){
            cin>>arr[i][j];
            dp[i][j] = 0;
        }
    }
    
    
    dp[0][1] = 1;
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++){
            if(arr[i][j]=='.')
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
    
    /*for(ll i=0;i<=h;i++){
        for(ll j=0;j<=w;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    
    
    cout<<dp[h][w]%mod<<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  if(n/1000 == n/100-n/1000*10 && n/100-n/1000*10 == n/10 - n/100*10){
    cout << "Yes" << endl;
  }
  else if(n/100 - n/1000*10 == n/10 - n/100*10 && n/10 - n/100*10 == n - n/10*10){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<vector>
#include<map>
#include <set>
#include<string>
#include <queue>
#include <stack>
#include <random>
#define INF 1000000001
#include<iostream>
#include<vector>
using ll = long long;


int main()
{    

    std::string s;
    std::cin >> s;

    int blue = 0;
    int red = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '0') red++;
        else blue++;
    }
   std::cout << s.size() - std::abs(red - blue) << std::endl;
   return 0;
    
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
//using fs = unordered_set;
//#define fs set//unordered_set
vector<ll> S(0);

ll FFi(ll i){
    if(S[i]==i)return i;
    return S[i]=FFi(S[i]);
    
}

void marge(ll a,ll b){
    ll aa=FFi(a),bb=FFi(b);
    if(aa==bb)return;
    ll maxx = (aa<bb)? aa:bb;
    S[aa]=maxx;
    S[bb]=maxx;
    FFi(a);
    FFi(b);
}


int main() {
    ll N,M;
    cin >> N >> M;
    vector<vector<ll>> A(N);
    for(ll i=0;i<N;i++)S.push_back(i);
    for(ll i=0;i<M;i++){
        ll sub1,sub2;
        cin >> sub1 >> sub2;
        marge(sub1-1, sub2-1);
     
        
    }
    for(ll i:S){
        FFi(i);
    }
    
    vector<ll> CO(N,0);
    for(ll i:S){
        CO[FFi(i)]++;
    }
    sort(CO.begin(), CO.end(), [](ll a,ll b){return a>b;});
    
    cout << CO[0] << endl;
    
    
}



Measured memory_bytes: 11092
using System;
using System.Linq;

class B{
  static void Main(){
    char[] Ar = Console.ReadLine().ToCharArray();
    char[] Br = Console.ReadLine().ToCharArray();
    string ans = "";
    int i = Br.Length;
    for (int j = 0; j < i; j++){
      ans += Ar[j].ToString();
      ans += Br[j].ToString();
    }
    if (Ar.Length - i == 1){
      ans += Ar[Ar.Length - 1].ToString();
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 17364
use std::io::stdin;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let (a, b, q) = {
        let ab:Vec<_> = st.trim().split(" ").map(|x| x.parse::<i64>().unwrap()).collect();
        (ab[0], ab[1], ab[2])
    };
    let mut s:Vec<i64> = Vec::new();
    let mut t:Vec<i64> = Vec::new();
    let f:i64 = -100000000000;
    let e:i64 = 100000000000;
    s.push(f);
    t.push(f);
    for _i in 0..a {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        s.push(st.trim().parse::<i64>().unwrap());
    };
    s.push(e);

    for _i in 0..b {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        t.push(st.trim().parse::<i64>().unwrap());
    };
    t.push(e);

    let mut i:i64 = 0;
    for _x in 0..q {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        i = st.trim().parse::<i64>().unwrap();
        let n = bisec(&mut s, &i);
        let m = bisec(&mut t, &i);
        let mut result:Vec<i64> = Vec::new();
        result.push(max(&s[n], &t[m])-i);
        result.push(i-min(&s[n-1], &t[m-1]));
        result.push(min(&(i-s[n]).abs(), &(i-t[m-1]).abs())+(s[n]-t[m-1]).abs());
        result.push(min(&(i-s[n-1]).abs(), &(i-t[m]).abs())+(s[n-1]-t[m]).abs());
        println!("{}", result.iter().min().unwrap());
    };
}

fn bisec(v:&Vec<i64>, num:&i64) -> usize {
    let mut l:usize = 0;
    let mut r = v.len() as usize;
    let mut m = (l+r)/2 as usize;
    while l < r {
        if num <= &v[m] {
            r = m;
        } else {
            l = m+1;
        };
        m = (l+r)/2;
    };
    l
}

fn max (a:&i64, b:&i64) -> i64 {
    if a < b {
        *b
    } else {
        *a
    }
}

fn min (a:&i64, b:&i64) -> i64 {
    if a > b {
        *b
    } else {
        *a
    }
}

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

int main() {
	int N, lev = 0, left = 0;
	string S;
	cin >> N >> S;
	for (int i = 0;i < N;i ++) {
		if (S[i]-')') lev ++;
		else lev --;
		if (!(lev + 1)) {
			left ++;
			lev ++;
		}
	}
	for (int i = 0;i < left;i ++) cout << '(';
	cout << S;
	for (int i = 0;i < lev;i ++) cout << ')';
	return 0;
}
/* 辞書順では'('[40番]の方が')'[41番]より先
だから、不足している'('の数だけ最左側に、不足している')'の数だけ最右側に置けばいい

現在の階層を0とする。'('が出る度に+1、')'が出る度に-1して、
もしも負の数になるなら最も右側に'('を追加して0にする。
この時、最後に出てきた階層だけ右側に')'を追加すれば、これは正しい文字列であり、しかも条件を満たす。
*/

Measured memory_bytes: 256
#include <cstdio>

const int MAXN = 500000 + 10;

int deg[MAXN];
int far[MAXN];
int pre[MAXN << 1], to[MAXN << 1], head[MAXN], wcnt;
int q[MAXN], ql, qr;
inline void addedge(int u, int v) {
	wcnt++;
	pre[wcnt]=head[u];
	head[u]=wcnt;
	to[wcnt]=v;
}

int main() {
	int i, n, m, u, v;
	
	scanf("%d %d", &n, &m);
	for(i=1; i<=n-1+m; i++){
		scanf("%d %d", &u, &v);
		deg[v]++;
		addedge(u, v);
	}
	
	ql=1;
	qr=0;
	for(i=1; i<=n; i++) if(!deg[i]) q[++qr]=i;
	while(ql<=qr){
		u=q[ql++];
		for(i=head[u]; i; i=pre[i]){
			deg[v=to[i]]--;
			far[v]=u;
			if(!deg[v]){
				q[++qr]=v;
			}
		}
	}
	
	for(i=1; i<=n; i++) printf("%d\n", far[i]);
	return 0;
}

Measured memory_bytes: 13440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 2000005;
const int MM = 1000000007;

int main()
{
	int D[4];
	for(int t = 0; t < 4; t++) scanf("%d", D+t);
	int N;
	scanf("%d", &N);
	ll ans = 0, cur = min({D[0]*4, D[1]*2, D[2]*1});
	ans = (N/2) * min(cur*2, D[3]*1ll) + (N%2) * cur;
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	while(1){
		int N;
		cin>>N;
		if(N==0)break;
		string c;
		cin>>c;
		int maisu[10];
		for(int i=0;i<N;i++){
			maisu[i]=0;
		}
		int ba=0;
		int turn=0;
		for(int i=0;i<c.size(); i++){
			if (c[i]=='M'){
				maisu[turn]++;
			}
			else if(c[i]=='S'){
				maisu[turn]+=1;
				ba += maisu[turn];
				maisu[turn]=0;
			}
			else{
				maisu[turn]+=1;
				maisu[turn] += ba;
				ba=0;
			}
			turn++;
			turn %= N;
		}
		sort(maisu,maisu+N);
		for(int i=0;i<N;i++){
			cout<<maisu[i]<<" ";
		}
		cout<<ba<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
S = gets.chomp

s1 = S[0..1].to_i
s2 = S[2..3].to_i

YY = (0..99)
MM = (1..12)

if YY.member?(s1) && MM.member?(s2)
  if MM.member?(s1) && YY.member?(s2)
    puts 'AMBIGUOUS'
  else
    puts 'YYMM'
  end
elsif MM.member?(s1) && YY.member?(s2)
  puts 'MMYY'
else
  puts 'NA'
end

Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int lcnt = 0, rcnt = 0;
    int l = 0, r = 0;
    // l:=) r:=(
    for(int i = 0; i < N; i++) {
        if(S[i] == ')') {
            l++;
            if(r == 0)
                lcnt++;
            r = max(0, r - 1);
        } else {
            r++;
        }
    }
    l = 0, r = 0;
    for(int i = N - 1; i >= 0; i--) {
        if(S[i] == ')') {
            l++;
        } else {
            r++;
            if(l == 0)
                rcnt++;
            l = max(0, l - 1);
        }
    }
    rep(i, lcnt) S = '(' + S;
    rep(j, rcnt) S = S + ')';
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m,i;
  cin>>n;
  vector<string> s(n);
  vector<int> k(n);
  for (i=0;i<n;i++) {
    cin>>s.at(i);
  }
  sort(s.begin(),s.end());
  m=1;
  k.at(0)=1;
  for (i=1;i<n;i++) {
    if (s.at(i-1)==s.at(i)) k.at(i)=k.at(i-1)+1;
    else k.at(i)=1;
    if (m<k.at(i)) m=k.at(i);
  }
  for (i=0;i<n;i++) if (k.at(i)==m) cout<<s.at(i)<<endl;
}

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

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

	int size = s.size();
	bool ans = true;
	for(int i = 0; i < size; i++){
		if(s[i] == t[i]){
			continue;
		}else{
			char S = s[i];
			char T = t[i];
			for(int j = 0; j < size; j++){
				if(s[j] == S){
					s[j] = T;
					if(j < i)
						ans = false;
				}else if(s[j] == T){
					s[j] = S;
					if(j < i)
						ans = false;
				}
			}
		}
		if(!ans)
			break;
	}

	if(ans){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int t[n],x[n],y[n];
  rep(i,0,n) cin>>t[i]>>x[i]>>y[i];
  int cx=0;
  int cy=0;
  int ct=0;
  bool p=true;
  rep(i,0,n){
    if(abs(cx-x[i])+abs(cy-y[i])>t[i]-ct) p=false;
    else if((t[i]-ct-abs(cx-x[i])-abs(cy-y[i]))%2!=0) p=false;
    cx=x[i];
    cy=y[i];
    ct=t[i];
  }
  if(p) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1408
# ABC076-B
N = int(input())
K = int(input())
ans_list = []
for a in range(N+1):
    tmp = 1
    b = N - a
    for i in range(a):
        tmp  *= 2
    tmp += b * K
    ans_list.append(tmp)   
print(min(ans_list))

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

    long long res1 = 0;
    for (long long i = 0, c = 0; i < n; i++) {
        c += a[i];
        if (i % 2 == 0 && c <= 0) {
            res1 += 1 - c;
            c = 1;
        } else if (i % 2 != 0 && c >= 0) {
            res1 += 1 + c;
            c = -1;
        }
    }

    long long res2 = 0;
    for (long long i = 0, c = 0; i < n; i++) {
        c += a[i];
        if (i % 2 == 0 && c >= 0) {
            res2 += 1 + c;
            c = -1;
        } else if (i % 2 != 0 && c <= 0) {
            res2 += 1 - c;
            c = 1;
        }
    }

    cout << min(res1, res2) << endl;
}


Measured memory_bytes: 1024
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @x,@k,@d = gets.split.map(&:to_i)
    @a = x - k * d
    @b = x + k * d
    @i = -a / (d * 2)
    @c = calc(i)
    @j = i + 1
    @d = calc(j)
  end

  def solve
    return a.abs if a >= 0
    return b.abs if b <= 0
    if c.abs < d.abs
      return c.abs
    else
      return d.abs
    end
  end

  def calc(i)
    a + 2 * d * i
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  string s;
  cin>>n;
  cin>>s;
  vector<int> cnt(26,0);
  int ans=0;
  int temp=0;
  REP(i,n-1){
    REP(j,i+1){
      for(int k=i+1;k<n;k++){
        if(s[j]==s[k]){
          cnt[s[j]-'a']=1;
        }
      }
    }
    REP(l,26){
      temp += cnt[l];
      cnt[l]=0;
    }
    ans = max(ans,temp);
    temp = 0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    COMinit();
    int n;
    cin >> n;
    n++;
    int x, y;
    VI pos(n + 1, -1);
    rep(i, n)
    {
        int a;
        cin >> a;
        if (pos[a] != -1)
        {
            cerr << a << endl;
            x = pos[a];
            y = i;
        }
        pos[a] = i;
    }
    cerr << x << " " << y << endl;
    rep(i, 1, n + 1)
    {
        ll ans = COM(n, i);
        ans -= COM(x + (n - 1 - y), i - 1);
        while (ans < 0)
            ans += MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 13568
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int n=(int)sqrt(x<<1);
    if (n*(n+1)<x<<1)
        ++n;
    cout<<n;
    return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int ans = INT_MAX;
    rep(i,n-k+1) {
        ans = min(ans, h[i+k-1]-h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
int DSU[200005];
int Rank[200005];
int find(int a)
{
	if(DSU[a]==a)
		return a;
	return DSU[a]=find(DSU[a]);
}
void Union(int a,int b)
{
	int x=find(a),y=find(b);
	if(Rank[x]==Rank[x])
	{
		Rank[x]++;
		DSU[y]=x;
	}
	else if(Rank[x]>Rank[y])
	{
		DSU[y]=x;
	}
	else
	{
		DSU[x]=y;
	}
	return;
}
void solve()
{
	int n,m,i;
	cin>>n>>m;
	for(i=0;i<=n;i++)
	{
		DSU[i]=i;
		Rank[i]=1;
	}
	for(i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		if(DSU[u]==DSU[v])
			continue;
		Union(u,v);
	}
	map<int,int> M;
	m=0;
	for(i=1;i<=n;i++)
	{
		M[find(i)]++;
		m=max(m,M[DSU[i]]);
	}
	cout<<m<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


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

int main(){
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++) cin >> c[i][j];
    }
    bool flag = true;
    for (int i = 0; i < 3; i++){
        int x = c[0][i] - c[0][(i + 1) % 3];
        int y = c[1][i] - c[1][(i + 1) % 3];
        int z = c[2][i] - c[2][(i + 1) % 3];
        if (!(x == y && y == z)) flag = false;
    }
    for (int i = 0; i < 3; i++){
        int x = c[i][0] - c[(i + 1) % 3][0];
        int y = c[i][1] - c[(i + 1) % 3][1];
        int z = c[i][2] - c[(i + 1) % 3][2];
        if (!(x == y && y == z)) flag = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int main(){
  int ans = 0;
  int depth = 0;
  string str;
  cin >> str;
  for(auto i : str){
    switch(i){
      case 'S':
        depth++;
        break;
      case 'T':
        if(depth == 0){
          ans += 1;
        }else{
          depth--;
        }
    }
  }
  cout << ans + depth << endl;;
}


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

int main()
{
	int n,i;
	cin>>n;
	int a[n],b[n-1];
	for(i=0;i<n;i++)
		cin>>b[i];
	a[n-1]=b[n-2];
	a[0]=b[0];
	for(i=n-2;i>0;i--)
		a[i]=min(b[i],b[i-1]);
	
	int ans=0;
	for(i=0;i<n;i++)
		ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

res = 0

for i in range(N - 1, -1, -1):
    if A[i + 1] > 0:
        if A[i + 1] > B[i]:
            res += B[i]
            B[i] = 0
        else:
            res += A[i + 1]
            B[i] -= A[i + 1]

    if B[i] > 0 and A[i] > 0:
        if B[i] > A[i]:
            res += A[i]
            A[i] = 0
        else:
            res += B[i]
            A[i] -= B[i]

print(res)

Measured memory_bytes: 24192
import java.util.*;

public class Main {

    static void dfs(int at, int prev) {
        if (prev != -1)
            counter[at] += counter[prev];

        for (Integer e : graph.get(at)) {
            if(e == prev) continue;
            dfs(e, at);
        }
    }

    static int N;
    static int Q;
    static List<List<Integer>> graph;
    static long[] counter;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        Q = Integer.parseInt(sc.next());
        counter = new long[N];
        graph = new ArrayList<>();

        for (int i = 0; i < N; ++i) graph.add(new ArrayList<>());

        for (int i = 0; i < N-1; ++i) {
            int a = Integer.parseInt(sc.next()) - 1;
            int b = Integer.parseInt(sc.next()) - 1;
            graph.get(a).add(b);
            graph.get(b).add(a);
        }

        for (int i = 0; i < Q; ++i) {
            int id = Integer.parseInt(sc.next()) - 1;
            int x = Integer.parseInt(sc.next());
            counter[id] += x;
        }

        dfs(0, -1);

        for (int i = 0; i < N; ++i)
            System.out.print(counter[i] + " ");
        System.out.println();
    }
}

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


long long ans;
long long N;
long long A[15];

int main(){
	cin >> N;
	ans = 1;
	for(long long i =0; i < N; i++){
		cin >> A[i];
		ans *= 3;
	}
	
	long long bad = 1;
	for(long long i =0; i < N; i++){
		if(A[i] % 2 == 0){
			bad *= 2;
		}else{
			bad *= 1;
		}
	}
	cout << ans - bad << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,val;}ee[M*2];
void add(int x,int y,int z){ee[++cnt].nxt=head[x],ee[cnt].to=y,ee[cnt].val=z,head[x]=cnt;}
*/


int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	ll a,b,c;
  	cin>>a>>b>>c;
  	if(a*b*4<(c-a-b)*(c-a-b)&&(c-a-b)>0)
  	cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256