akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;
  int ovr = 1, sum = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      if (sum < a + b) {
        Yes();
        sum++;
      } else {
        No();
      }
    } else if (s[i] == 'b') {
      if (sum < a + b && ovr <= b) {
        Yes();
        sum++;
      } else {
        No();
      }
      ovr++;
    } else {
      No();
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main(){
  while(1){
  int m,f,r;
  cin>>m>>f>>r;
  if(m== -1 && f== -1 && r== -1) break;
  string ans;
  if(m== -1||f== -1) ans="F";
  else if(m+f>=80) ans="A";
  else if(m+f>=65) ans="B";
  else if(m+f>=50) ans="C";
  else if(m+f>=30){
    if(r>=50) ans="C";
    else ans="D";
    }
  else ans="F";
  
  cout<<ans<<endl;
}

return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <stdlib.h>

using namespace std;

void swap(int* x,int* y)
{
    int p = 0;
    
    p = *x;
    *x = *y;
    *y = p;
    
    return ;
}

int main()
{
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if(a > b)swap(&a,&b);
    
    if(b > c)swap(&b,&c);
    
    if(a > b)swap(&a,&b);
    
    cout << a << " " <<  b << " " <<  c << endl;
    
    return 0;
    
}


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

using namespace std;

const int MX = 26;

char s[MX + 1];

int main() {
	ignore = scanf("%s", s);
	
	int n = strlen(s);
	if (n == 26) {
		int i = 25;
		char c = 'a' - 1;
		while (i >= 0 && s[i] > c) {
			c = s[i];
			i--;
		}
		
		if (i == -1) {
			printf("%d\n", -1);
			return 0;
		}
		
		c = 'z' + 1;
		for (int j = i + 1; j < n; j++) if (s[j] < c && s[j] > s[i]) c = s[j];
		
		s[i] = c;
		s[i + 1] = 0;
	}
	else {
		set<char> S;
		for (int i = 0; i < n; i++) S.insert(s[i]);
		
		char c = 'a';
		while (S.count(c) == 1) c++;
		
		s[n] = c;
		s[n + 1] = 0;
	}
	
	printf("%s\n", s);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> idx(n);
  REP(i, n) {
    int h;
    cin >> h;
    h--;
    idx[h] = i;
  }
  EACH(v, idx) {
    cout << v + 1 << endl;
  }
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 1152
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int N,K,i,cnt=1,j,mn=INF;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>N>>K;
  for(i=0;i<=N;i++){
    cnt=1;
    for(j=0;j<i;j++){
      cnt*=2;
    }
    for(j=0;j<N-i;j++){
      cnt+=K;
    }
    mn=min(mn, cnt);
  }
  P(mn);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int n,dis[505][505],ans;
bool flag[505][505];
queue<int>qx,qy;
void bfs(int x,int y)
{
	dis[x][y]--;
	flag[x][y]=0;
	qx.push(x);
	qy.push(y);
	while(!qx.empty())
	{
		int x=qx.front();
		int y=qy.front();
		qx.pop();
		qy.pop();
		for(int k=0;k<4;k++)
		{
			int xx=x+dx[k];
			int yy=y+dy[k];
			if(xx>=1&&xx<=n&&yy>=1&&yy<=n&&dis[xx][yy]>dis[x][y]+flag[xx][yy])
			{
				dis[xx][yy]=dis[x][y]+flag[xx][yy];
				qx.push(xx);
				qy.push(yy);
			}
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	    flag[i][j]=1,dis[i][j]=min(min(i,n-i+1),min(j,n-j+1));
	for(int i=1;i<=n*n;i++)
	{
		int x,y;
		scanf("%d",&x);
		y=(x-1)%n+1;
		x=(x-1)/n+1;
		ans+=dis[x][y]-1;
		bfs(x,y);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct D{
    int pnt,id;
    D(int a,int b):pnt(a),id(b){}
    D(){}

    bool operator<(const D &d)const{
        return pnt!=d.pnt?pnt<d.pnt:id>d.id;
    }
};

int N,R,L;
int d[1000000],t[1000000],x[1000000];
int pnt[100000];
int cnt[100000];
signed main(){
    cin>>N>>R>>L;
    for(int i=0;i<R;i++)cin>>d[i]>>t[i]>>x[i],d[i]--;

    priority_queue<D>Q;

    for(int i=0;i<N;i++)Q.push(D(0,i));

    int cur=0;
    for(int i=0;i<L;i++){
        while(Q.top().pnt!=pnt[Q.top().id])Q.pop();
        cnt[Q.top().id]++;

        while(cur<R&&t[cur]==i+1){
            pnt[d[cur]]+=x[cur];
            Q.push(D(pnt[d[cur]],d[cur]));
            cur++;
        }
    }

    int de=0;
    //for(int i=0;i<N;i++)de+=cnt[i];cout<<"de is "<<de<<endl;
    int ma=0;
    for(int i=1;i<N;i++)if(cnt[ma]<cnt[i])ma=i;
    cout<<ma+1<<endl;
    return 0;
}

Measured memory_bytes: 40408
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> vec(5),ae(5);
	rep(i,5){
		cin >> vec[i];
		ae[i] = (vec[i] + 9) / 10 * 10;
	}
	int minv = INF;
	rep(i,5){
		int sum = 0;
		rep(j,5){
			if(i == j) continue;
			sum += ae[j];
		}
		minv = min(minv,sum + vec[i]);
	}
	cout << minv << '\n';
	return 0;	
}


Measured memory_bytes: 256
program speedrun
    use iso_fortran_env
implicit none
integer::N
integer(int64),allocatable,dimension(:)::A,B
integer(int64),allocatable,dimension(:)::A2,B2
integer,allocatable,dimension(:):: B2Table
integer::i,B2ind,A2ind
integer::k
integer(int64)::x
read*,N
allocate(B(0:N-1),A(0:N-1),B2(0:N),A2(0:2*N-2),B2Table(0:N))
read*,A(0:N-1)
read*,B(0:N-1)
do i=0,N-2
    B2(i)=xor(B(i),B(i+1))
end do
B2(N-1)=xor(B(N-1),B(0))
B2(N)=-1
do i=0,N-2
    A2(i)=xor(A(i),A(i+1))
    A2(i+N)=A2(i)
end do
A2(N-1)=xor(A(N-1),A(0))

B2ind=0;A2ind=0

call KMP_C_T(N,B2(0:N-1),B2Table(0:N-1))

do while(B2ind+A2ind <2*N-1 )
    do while(A2ind<2*N-1.and.B2ind<N)
        if(B2(B2ind)==A2(B2ind+A2ind))then
            B2ind=B2ind+1
        else
            A2ind=A2ind+B2ind-B2Table(B2ind)
            if(B2ind>0)B2ind=B2Table(B2ind)
        end if
    end do
    if(B2ind==N)then
        k=A2ind
        if(k>=N)exit
        x=xor(B(0),A(K))
        print"(i0,A,i0)",k," ",x
        A2ind=A2ind+B2ind-B2Table(B2ind)
        B2ind=B2Table(B2ind)
    endif
end do
contains
subroutine KMP_C_T(NN,AA,T)
    integer::NN
    integer(int64),intent(in)::AA(0:N)
    integer,intent(inout)::T(0:N)
    integer::ii,j
    ii = 2
    j = 0 
    T(0) = -1
    T(1) = 0

    do while (ii<=NN)
        if (AA(ii - 1) == AA(j))then
            T(ii) = j + 1
            ii = ii + 1
            j = j + 1
        else if (j > 0)then
            j = T(j)
        else
            T(ii) = 0
            ii = ii + 1
        endif
    end do
end subroutine
end program speedrun

Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200200;
int a[N];
int b[N];
int main(){
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	while(k--){
		for(int i=1;i<=n;i++)b[i]=0;
		for(int i=1;i<=n;i++){
			b[max(1,i-a[i])]++;
			b[min(n+1,i+a[i]+1)]--;
		}
		for(int i=1;i<=n;i++)b[i]+=b[i-1];
		for(int i=1;i<=n;i++)if(b[i]!=a[i])goto no;
		break;
		no:;
		for(int i=1;i<=n;i++)a[i]=b[i];
	}
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
	cout<<endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

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

  int n;
  cin >> n;
  vector<ld> p(n);
  trav(i, p) cin >> i;
  vector<vector<ld>> dp(n + 1, vector<ld>(n + 1));
  dp[0][0] = 1;
  rep(i, 0, n) {
    rep(j, 0, n) {
      dp[i + 1][j + 1] += p[i] * dp[i][j];
      dp[i + 1][j] += (1 - p[i]) * dp[i][j];
    }
  }
  auto res = 0.L;
  auto lb = (n + 1) / 2;
  rep(i, lb, n + 1)
    res += dp[n][i];
  cout << fixed << setprecision(11) << res << '\n';
}


Measured memory_bytes: 141056
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int r[4005]={0},g[4005]={0},b[4005]={0};
int n;
string s;
int main(void){
	cin>>n>>s;
	FORN(i,1,n+1){
		r[i]=r[i-1];
		g[i]=g[i-1];
		b[i]=b[i-1];
		if(s[i-1]=='R')r[i]++;
		else if(s[i-1]=='G')g[i]++;
		else b[i]++;
	}
	/*REP(i,n+1)cout<<r[i]<<' ';
	cout<<endl;
	REP(i,n+1)cout<<g[i]<<' ';
	cout<<endl;
	REP(i,n+1)cout<<b[i]<<' ';
	cout<<endl;*/
	ll ans=0;
	FORN(i,1,n+1){
		FORN(j,i+2,n+1){
//			cout<<i<<' '<<j<<' ';
			if((s[i-1]=='R'&&s[j-1]=='G')||(s[i-1]=='G'&&s[j-1]=='R')){//B
				ans+=b[j]-b[i-1];
//				cout<<b[j]-b[i-1]<<' ';
				if((i+j)%2==0){
					if(s[(i+j)/2-1]=='B'){
						ans--;
//						cout<<"B";
					}
				}
			}
			else if((s[i-1]=='R'&&s[j-1]=='B')||(s[i-1]=='B'&&s[j-1]=='R')){//G
				ans+=g[j]-g[i-1];
//				cout<<g[j]-g[i-1]<<' ';
				if((i+j)%2==0){
					if(s[(i+j)/2-1]=='G'){
						ans--;
//						cout<<"G";
					}
				}
			}
			else if((s[i-1]=='G'&&s[j-1]=='B')||(s[i-1]=='B'&&s[j-1]=='G')){//R
				ans+=r[j]-r[i-1];
//				cout<<r[j]-r[i-1]<<' ';
				if((i+j)%2==0){
					if(s[(i+j)/2-1]=='R'){
						ans--;
//						cout<<"R";
					}
				}
			}
//			cout<<endl;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

// 0-indexed, 半開
template <typename T> struct BIT {
  private:
    int n;
    vector<T> dat;

  public:
    BIT(vector<T> v) : n(v.size()) {
        dat.assign(n + 1, 0);
        for(int i = 0; i < n; i++)
            dat[i + 1] = v[i];
        for(int i = 1; i < n; i++)
            if(i + (i & -i) <= n) dat[i + (i & -i)] += dat[i];
    }
    BIT(int n) : n(n) { dat.assign(n + 1, 0); }
    void add(int k, T a) {
        for(k++; k <= n; k += k & -k)
            dat[k] += a;
    }
    // [0,a)
    T sum(int a) {
        T ret = 0;
        for(; a > 0; a -= a & -a)
            ret += dat[a];
        return ret;
    }
    // [a,b)
    T sum(int a, int b) { return sum(b) - sum(a); }
    int lowerBound(int w) {
        if(w <= 0) return 0;
        int x = 0;
        for(int k = 1 << int(log2(n)); k; k /= 2) {
            if(x + k <= n && dat[x + k] < w) {
                x += k;
                w -= dat[x];
            }
        }
        return x + 1;
    }
};

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

    ll n, k;
    cin >> n >> k;
    V<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] -= k;
    }
    V<ll> sum(n + 1, 0);
    rep(i, n) sum[i + 1] = sum[i] + a[i];
    V<int> p(n + 1);
    rep(i, n + 1) p[i] = i;
    sort(ALL(p), [&](int a, int b) {
        return sum[a] != sum[b] ? sum[a] < sum[b] : a < b;
    });
    BIT<int> bit(n + 10);
    ll ans = 0;
    for(int i : p) {
        ans += i - bit.sum(i);
        bit.add(i, 1);
    }
    cout << n * (n + 1) / 2 - ans << endl;

    return 0;
}

Measured memory_bytes: 4992
//20200517 D
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		List[] e=new List[n];
		for(int i=0;i<n;i++){
			e[i]=new ArrayList<Integer>();
		}
		int[] q=new int [n];
      	int a;
      	int b;
		for(int i=0;i<m;i++){
			a=sc.nextInt();
			b=sc.nextInt();
          	e[a-1].add(b);
          	e[b-1].add(a);
        }
      	int h=0; 
        int f=0;
        q[0]=1;
      	boolean[] v=new boolean[n];
      	v[0]=true;
      	List<Integer> t;
      	int s;
      	int[] ans=new int[n-1];
		while(h<n){
           // System.out.println(h);
 			t=e[q[h]-1];
			for(int i=0;i<t.size();i++){
              	s=t.get(i);
            	if(!v[s-1]){
                  f++;
                	q[f]=s;
                  	v[s-1]=true;
                  	ans[s-2]=q[h];
                }
            }
          	h++;
        } 
        if(true){
			System.out.println("Yes");
          for(int i=0;i<n-1;i++){
			System.out.println(ans[i]);
		  }
		}else{
			System.out.println("No");
		}
    }
}

Measured memory_bytes: 69100
#include <iostream>

using namespace std;

int main() {
	int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (d2 < d1) {
  	cout << 1;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*1 2
3 1
3*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 long long int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
 
  
      long long int dis=abs(b-a);
      long long int rel=v-w;
      double tt=double(dis)/double(rel);
      double tim=(double)t;
      if(dis>0 && rel<=0)
      {
          cout<<"NO"<<endl;
          return 0;
      }
      if(tt>tim)
      cout<<"NO"<<endl;
      else
      cout<<"YES"<<endl;
  
}

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

using namespace std;

string i2m(int n) {
    char dc[4] = {'i', 'x', 'c', 'm'};
    string mstr = "";
    for (int i = 0; i < 4; ++i) {
        int d = n % 10;
        if (d > 0) {
            mstr = dc[i] + mstr;
        }
        if (d > 1) {
            mstr = char(d + '0') + mstr;
        }
        n /= 10;
    }
    return mstr;
}

int m2i(string s) {
    int n = 0;
    int d = 1;
    for (int i = 0; i < (int)s.length(); ++i) {
        if ('2' <= s[i] && s[i] <= '9') {
            d = s[i] - '0';
        } else {
            if (s[i] == 'm') {
                n += d * 1000;
            } else if (s[i] == 'c') {
                n += d * 100;
            } else if (s[i] == 'x') {
                n += d * 10;
            } else {
                n += d;
            }
            d = 1;
        }
    }
    return n;
}

int main() {
    int n;
    string s1, s2;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s1 >> s2;
        cout << i2m(m2i(s1) + m2i(s2)) << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>

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

    if ((a + b) % 2 == 0)
    {
        std::cout << (a + b) / 2 << std::endl;
    }
    else
    {
        std::cout << "IMPOSSIBLE" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int n,m;
vi g[200005];
bool vis[200005];
int dfs(int x,int cnt){
	vis[x]=1;
	int tmp=cnt;
	rep(i,g[x].size()){
		if(!vis[g[x][i]]){
			cnt+=dfs(g[x][i],tmp);
		}
	}
	re cnt+1;
}
int main(){
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	int ans=0;
	fill(vis,0);
	rep(i,n){
		if(!vis[i]){
			ans=max(ans,dfs(i,0));
		}
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 24048
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		solve();
	}

	public static void solve() {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		final int MOD = 1000000007;

		//入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		//処理
		boolean f = false;
		for(int i = 0; i < b; i++){
			if(a * i % b == c) f = true;
		}

		//出力	
		out.println(f ? "YES" : "NO");
		out.flush();
	}

	static class Pair{
		int a,b;
		public Pair(int a, int b){
			this.a = a;
			this.b = b;
		}
	}
}

Measured memory_bytes: 21844
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
ll k;bool check(vi v){
	for(ll i=0;i<v.size();i++) if(v[i]>k) return 1;
	return 0;
}
int main(){
	ll n,m,i,j,w,s=1e10;cin>>n>>m>>k;vs v(n);for(i=0;i<n;i++) cin>>v[i];
	for(i=0;i<(1<<(n-1));i++){
		ll c=0,k=i,ss=0,e=0;vi x;
		while(k){
			if(k%2) x.pb(c);
			k/=2;c++;
		}vvi a(2,vi(x.size()+1,0));ss+=x.size();
		for(j=0;j<n;j++){
			a[0][e]+=v[j][0]-48;
			if(e<x.size()&&x[e]==j) e++;
		}if(check(a[0])) ss+=1e10;
		a[1]=a[0];
		for(j=1;j<m;j++){
			e=0;
			for(w=0;w<n;w++){
				a[1][e]+=v[w][j]-48;
				if(e<x.size()&&x[e]==w) e++;
			}
//			print(a[1]);
			if(check(a[1])){
				for(w=0;w<a[0].size();w++) a[1][w]-=a[0][w];
				ss++;
			}if(check(a[1])) ss+=1e10;
			a[0]=a[1];
//			print(a[1]);
//			cout<<ss<<endl<<endl;
		}s=min(ss,s);
//		cout<<endl;
	}cout<<s<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int ans = 0;
    int n;
    cin >> n;
    
    for(int i = 1; i <= n; i += 2)
    {
        int cnt = 0;
        for(int k = 1; k <= i; k++)
        {
            if(i % k == 0)
            {
                cnt++;
            }
        }
        
        if(cnt == 8)
        {
            ans++;
        }
    }
    cout << ans;
    
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string s, t;
	cin >> s >> t;
	vector<vector<int>> lcs(s.size(), vector<int>(t.size()));
	lcs[0][0] = (s[0] == t[0]) ? 1 : 0;
	for (int i = 1; i < s.size(); i++)
	{
		if (s[i] == t[0]) lcs[i][0] = 1;
		else lcs[i][0] = max(lcs[i - 1][0], 0);
	}
	for (int i = 1; i < t.size(); i++)
	{
		if (t[i] == s[0]) lcs[0][i] = 1;
		else lcs[0][i] = max(lcs[0][i - 1], 0);
	}

	for (int i = 1; i < s.size(); i++)
	{
		for (int j = 1; j < t.size(); j++)
		{
			if (s[i] == t[j]) lcs[i][j] = lcs[i - 1][j - 1] + 1;
			else lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1]);
		}
	}
	//cout << lcs[s.size() - 1][t.size() - 1] << endl;
	string res = "";
	int i = s.size() - 1;
	int j = t.size() - 1;
	while (0 < i && 0 < j)
	{
		if (lcs[i][j] == lcs[i - 1][j]) i--;
		else if (lcs[i][j] == lcs[i][j - 1]) j--;
		else
		{
			res = s[i] + res;
			i--;
			j--;
		}
	}
	if (i == 0)
	{
		for (int k = 0; k <= j; k++)
		{
			if (s[0] == t[k])
			{
				res = s[0] + res;
				break;
			}
		}
	}
	else if (j == 0)
	{
		for (int k = 0; k <= i; k++)
		{
			if (t[0] == s[k])
			{
				res = t[0] + res;
				break;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  int pre = -999;
  rep(i,n) cin >> h[i];
  rep(i,n) {
    if (pre <= h[i] - 1) {
      pre = h[i] -1;
    } else if (pre <= h[i]) {
      pre = h[i];
    } else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 640
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

c = [list(map(int,input().split())) for i in range(3)]

a =[0]*3
b =[0]*3

for i in range(3):
    b[i] = c[0][i] - a[0]

for i in range(1,3):
    a[i] = c[i][0] - b[0]

for i in range(3):
    for j in range(3):
        if (a[i] + b[j] != c[i][j]):
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define ll long long
#define testfor(T) ll T; cin>>T; while(T--)
using namespace std;
void quickstart()
{
	ios_base::sync_with_stdio(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}
int main()
{
	quickstart();
	double b;
	ll a;
	cin >> a >> b;
	ll product=(a*(ll)(b*100+0.5))/100;
	cout<<product;
	return 0;
}

Measured memory_bytes: 3736
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair <PP,bitset<8100> > Pv;

static const double EPS = 1e-8;


int tx[] = {-1,0,1,0};
int ty[] = {0,1,0,-1};

char buf[1000000];

int main(){
	int m,n;

	bitset<1000000> mask;

	while(~scanf("%d",&n)){
		if(n==0) break;
		scanf("%d",&m);
		scanf("%s",buf);

		deque<char> que;
		int tmp = 0;
		int res = 0;
		int state = -1;
		for(int i=0;i<m;i++){
			que.push_back(buf[i]);
			
			if(que.size()==3){
				char f = que[0];
				char m = que[1];
				char r = que[2];
				
				if(f=='I' && m == 'O' && r == 'I'){
					tmp++;
					if(tmp>=n) res++;
					que.pop_front();
					que.pop_front();
				}
				else{
					tmp=0;
					que.pop_front();
				}
			}

		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
int len = 200000;
vector<int>L(len / 2), R(len / 2);
int merge(vector<int>&a, int l, int mid, int r) {
	int n1 = mid - l;
	int n2 = r - mid;
	rep(i, 0, n1)L[i] = a[l + i];
	L[n1] = INF;
	rep(i, 0, n2)R[i] = a[mid + i];
	R[n2] = INF;
	int ret(0), i(0), j(0);
	rep(k, l, r) {
		if (L[i] < R[j])a[k] = L[i++];
		else {
			a[k] = R[j++];
			ret += n1 - i;
		}
	}
	return ret;
}
int mergeSort(vector<int>&a, int l, int r) {
	if (r - l > 1) {
		int mid = (l + r) / 2;
		return mergeSort(a, l, mid) + mergeSort(a, mid, r) + merge(a, l, mid, r);
	}
	else return 0;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	cout << mergeSort(v, 0, N) << endl;
	return 0;
}

Measured memory_bytes: 5996
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		var dp0 = DFS0(0, V);
		var dp1 = DFS1(0, dp0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long[] DFS0(int u, int p)
	{
		var dp = new long[V];
		var st = new Stack<A0>();
		st.Push(new A0(u, p));
		while (st.Count > 0)
		{
			var f = st.Pop();
			if (f.p >= 0)
			{
				dp[f.u] = 1L;
				es[f.u].Remove(f.p);
				if (es[f.u].Count == 0) continue;
				st.Push(new A0(f.u, -1));
				foreach (var v in es[f.u]) st.Push(new A0(v, f.u));
			}
			else foreach (var v in es[f.u]) dp[f.u] = dp[f.u] * (dp[v] + 1) % Mod;
		}
		return dp;
	}
	long[] DFS1(int u, long[] dp0)
	{
		var dp = new long[V];
		var st = new Stack<int>();
		st.Push(u);
		var y = new long[V];
		while (st.Count > 0)
		{
			u = st.Pop();
			var W = es[u].Count;
			if (W == 0) continue;
			y[W - 1] = 1;
			for (var i = W - 2; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i + 1]] + 1) % Mod;
			var x = 1L;
			for (var i = 0; i < W; i++)
			{
				dp[es[u][i]] = (dp[u] + 1) * x % Mod * y[i] % Mod;
				x = x * (dp0[es[u][i]] + 1) % Mod;
			}
			foreach (var v in es[u]) st.Push(v);
		}
		return dp;
	}
}
struct A0 { public int u, p; public A0(int u, int p) { this.u = u; this.p = p; } }


Measured memory_bytes: 36604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int main(void){
    int n,m; cin >> n >> m;
    vector< int > p[100005];
    rep(i,n){
        int a, b; cin >> a >> b;
        p[a].push_back(b);
    }
    //rep(i,n) cout << p[i].second << " " << p[i].first << endl;
    priority_queue<int> que;
    ll ans = 0;
    for(int i=1;i<=m;i++){
        for(int j=0;j<p[i].size();j++){
            que.push(p[i][j]);
        }
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 5632
def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


A, B = map(int, input().split())
ad = set(prime_factorization(A))
bd = set(prime_factorization(B))

cnt = 0
for a in ad:
    if a in bd:
        cnt += 1
print(cnt+1)


Measured memory_bytes: 9296
#include<bits/stdc++.h>
using namespace std;
string str;
  
bool solve(){
   
  while(1){
    if((int)str.size()<=3){
      if(str=="ABC")return true;
      else return false;
    }
  
    bool flag=false;
    string tmp="";
    bool flg[3]={};
    for(int i=0;i<(int)str.size();i++){
      if(i+2<(int)str.size()&&
         str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C'){
        i+=2;
        tmp.push_back('?');
        flag=true;
      }else{
        tmp.push_back(str[i]);
        flg[ str[i]-'A' ] = true;
      }
    }
    if(flag==false)return false;    
     
    char ch='?';
  
    if(flg[0]&&flg[1]&&!flg[2])ch='C';
    else if(flg[0]&&!flg[1]&&flg[2])ch='B';
    else if(!flg[0]&&flg[1]&&flg[2])ch='A';
    else return false;
  
    for(int i=0;i<(int)tmp.size();i++)
      if(tmp[i]=='?')tmp[i]=ch;
  
    str=tmp;
    
  }
  return true;
}
int main(){
  
  cin>>str;
  if(solve())cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3240
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

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

    double theta_h, theta_m;

    theta_h = (360. - 360. / 12 * (h + m / 60.) + 90.) * M_PI / 180.;
    theta_m = (360. - 360. / 60 * m + 90.) * M_PI / 180.;
    double x_h, x_m, y_h, y_m;
    x_h = a * cos(theta_h);
    y_h = a * sin(theta_h);
    x_m = b * cos(theta_m);
    y_m = b * sin(theta_m);
    // cout << (360. - 360. / 12 * (h + m / 60) + 90.) << endl;
    // cout << (360. - 360. / 60 * m + 90.) << endl;
    // cout << x_h << " " << y_h << endl;
    // cout << x_m << " " << y_m << endl;
    double xd = x_h - x_m;
    double yd = y_h - y_m;

    double l = sqrt(xd * xd + yd * yd);
    cout << fixed << setprecision(20) << l;

    return 0;

}

Measured memory_bytes: 4164
n_len = int(input())
n_list = [int(x) for x in input().split()]
flag = 0

n_border = 0

for ind in range(n_len - 1):
    n1 = n_list[ind]
    n2 = n_list[ind+1]
    if n1 - 1 > n_border:
        n_border = n1 - 1
    #print(n1,n2,n_border)
    if (n1 <= n2) | (n1 - 1 <= n2) & (n_border <= n2):
        pass
    else:
        flag = 1
        break
        
if flag:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 14396
package main

import "fmt"

func main() {
	var N, a0, a1, cnt, b int
	// b -n , 0, +n
	fmt.Scan(&N)
	fmt.Scan(&a0)
	for i := 1; i < N; i++ {
		fmt.Scan(&a1)
		if b*(a1-a0) < 0 {
			cnt++
			b = 0
		} else if a1-a0 != 0 {
			b = a1 - a0
		}
		a0 = a1
	}
	fmt.Println(cnt + 1)
}


Measured memory_bytes: 5504
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
      int count = 0;
      count += (n*(n-1))/2;
      count += (m*(m-1))/2;
      System.out.println(count);
	}
}


Measured memory_bytes: 35768
h, w, k = map(int, input().split())
A = [input() for i in range(h)]

min_num = float("inf")
for i in range(1<<(h-1)):
    c = 0
    d = {0:0}
    bar = 0
    for ii in range(1,h):
        if i&(1<<(ii-1)):
            c += 1
            bar += 1
        d[ii] = c

    # print(bin(i), bar, d)
    ss = [0]*(c+1)
    invalid = False
    for wi in range(w):
        flag = False
        ss_tmp = [0]*(c+1)
        for hi in range(h):
            if A[hi][wi] == "1":
                ss_tmp[d[hi]] += 1
                ss[d[hi]] += 1
                if ss_tmp[d[hi]] > k:
                    invalid = True
                if ss[d[hi]] > k:
                    flag = True

        if flag:
            ss = ss_tmp
            bar += 1
        # print(wi, flag, bar)
        # print(ss, ss_tmp)

    if not invalid:
        min_num = min(min_num, bar)

    # from right
    bar = bin(i).count("1")
    ss = [0] * (c + 1)
    invalid = False
    for wi in range(w-1, -1, -1):
        flag = False
        ss_tmp = [0] * (c + 1)
        for hi in range(h):
            if A[hi][wi] == "1":
                ss_tmp[d[hi]] += 1
                ss[d[hi]] += 1
                if ss_tmp[d[hi]] > k:
                    invalid = True
                if ss[d[hi]] > k:
                    flag = True

        if flag:
            ss = ss_tmp
            bar += 1
        # print(wi, flag, bar)
        # print(ss, ss_tmp)

    if not invalid:
        min_num = min(min_num, bar)

print(min_num)

Measured memory_bytes: 48732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int c[] = new int[5];
            int sum[] = new int[5];
            for (int i = 0; i < 5; i++) {
                c[i] = Integer.parseInt(in.next());
            }


            for (int i = 0; i < 5; i++) {
                sum[i] = c[i];
                for (int j = 0; j < 5; j++) {
                    if (j != i) {
                        if (c[j] % 10 == 0) {
                            sum[i] += c[j];
                        } else {
                            sum[i] += c[j] + 10 - c[j] % 10;
                        }
                    }
                }
            }
            // 出力
            Arrays.sort(sum);
            out.println(sum[0]);

        }

    }
}



Measured memory_bytes: 21844
s = input()
flg = 0
k = 0
if s[0] == "A":
    for i in range(1, len(s)):
        if s[i] == "C" and i != 1 and i != len(s) -1:
            if flg == 0:
                flg = 1
                k = i
            else:
                print("WA")
                exit()
    if k == 0:
        print("WA")
        exit()
    else:
        for j in range(1, len(s)):
            if s[j].isupper():
                if j != k:
                    print("WA")
                    exit()
            else:
                continue
else:
    print("WA")
    exit()
    
print("AC" if flg == 1 else "WA")

Measured memory_bytes: 8944
# coding: utf-8
N=int(input())
S=[]
T=[]
for i in range(N):
    S.append(input())
M=int(input())
for i in range(M):
    T.append(input())
S_=list(set(S))
ans=0
for i in range(len(S_)):
    ns=S.count(S_[i])
    nt=T.count(S_[i])
    ans=max(ans,ns-nt)
print(ans)

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

using namespace std;

const int N = 100100;

int a[N];
int dp[N];

vector <int> adj[N];


int dfs(int a) {

	for (int u: adj[a]) {
		dfs(u);
	}
	vector <int> v;
	if(adj[a].size() == 0) return dp[a] = 0;
	for (int u: adj[a]) {
		v.push_back(dp[u]);
	}

	sort(v.begin(),v.end());
	reverse(v.begin(), v.end());
	dp[a] = 0;
	for (int i = 0; i < adj[a].size(); ++i) {
		dp[a] = max(dp[a],v[i]+i+1);
	}
	return dp[a];

}


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

	for (int i = 1; i < n; ++i) {
		cin >> a[i];
		a[i]--;
		adj[a[i]].push_back(i);
	}

	printf("%d\n",dfs(0));


	
}

Measured memory_bytes: 14336
#include <stdio.h>
#include <string.h>
#define INFTY 1000000000
#define MAX 500000
int l,m,r,i,j,k;
int count;
void marge(int A[],int l,int m,int r){
  int a1,a2;
  a1 = m - l;
  a2 = r - m;
  int Left[a1];
  int Right[a2];
  for(i=0;i<a1;i++){
    Left[i]=A[l+i];
  }
  for(j=0;j<a2;j++){
    Right[j]= A[m+j];
  }
  Left[a1]= INFTY;
  Right[a2] = INFTY;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    count = count +1;
    
    if(Left[i]<=Right[j]){
      A[k] = Left[i];
      i = i+1;
    }
    else {
      A[k]=Right[j];
      j=j+1;
    }
  }
}

void mergesort(int A[],int left,int right){
  int mid;
  if(left+1 < right){
 
    mid = (left + right)/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    marge(A,left,mid,right);
  }
}

int main(){
  int n,p;
  int A[MAX];
  scanf("%d",&n);
  for(p=0;p<n;p++){
    scanf("%d",&A[p]);
  }
  mergesort(A,0,n);

  for(p=0;p<n;p++){
    if(p!=n-1){
    printf("%d",A[p]);
    printf(" ");
    }
    else if (p==n-1){
      printf("%d",A[p]);
    }
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

  
      



Measured memory_bytes: 5604
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,x,a[105];

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n >> x;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    sort(a + 1,a + 1 + n);
    int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        x -= a[i];
        if(x <= 0)
        {
            if(x == 0) rc(ans + 1);
            else rc(ans);
        }
        ans++;
    }
    rc(n - 1);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int a = 1;
    int ans = 0;
    while (a < B){
      a += (A-1);
      ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int N = Integer.parseInt(line);
        for (int i=0; i<N; i++){
            String l = br.readLine();
            Scanner sc = new Scanner(l);
            
            int a[];
            a = new int[3];
            for (int j=0; j<3; j++){
                a[j] = sc.nextInt();
            }
            Arrays.sort(a);
            if ((a[0]*a[0] + a[1]*a[1]) == a[2]*a[2]){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}

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

using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  cin.ignore();
  int ans = 0;
  if(x == 3){
    ans += 100000;
  } else if(x == 2){
    ans += 200000;
  } else if(x == 1){
    ans += 300000;
  }

    if(y == 3){
    ans += 100000;
  } else if(y == 2){
    ans += 200000;
  } else if(y == 1){
    ans += 300000;
  }

    if((x == 1) && (y==1)){
      ans += 400000;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int H, W; cin >> H >> W;
  string t(W + 2, '#'), s;
  puts(t.c_str());
  while (H--) {cin >> s; printf("#%s#\n", s.c_str());}
  cout << t;}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
 
long long int l[90]={0};
 
int main(){
    int n;
    cin >> n;
    l[0] = 2;
    l[1] = 1;
    for(int i=2;i<=n;++i){
        l[i] = l[i-1] + l[i-2];
    }
 
    cout << l[n] << endl;
 
    return 0;
}

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

using namespace std;

int main()
{
    int n;
   cin>>n;
   //char ch[250]={};
   string ch;
   cin>>ch;
   if(n%2==1) {
    cout<< " No";
    return 0;
   }
   for(int i=0; i<n/2; ++i)
   {
       if(ch[i]!= ch[n/2+i]){
        cout<<"No";
        return 0;
       }
   }
   cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;;
typedef long long ll;
typedef pair<ll,ll> PII;
int main()
{
	ll n,k,d;
	scanf("%lld %lld %lld",&n,&k,&d);
	string eles;
	cin>>eles;

	deque<ll> front,back;
	rep(i,0,n-1) if(eles[i]=='o'){
		front.push_back(i+1);
		i+=d;}

	if(front.size()>=k+1) return 0;
	else{
		per(i,n-1,0) if(eles[i]=='o'){
			back.push_front(i+1);
			i-=d;
		}
		deque<ll> anses(k,-1);
		set_intersection(all(front),all(back),anses.begin());
		rep(i,0,anses.size()-1){
			if(anses[i]==-1) break;
			cout<<anses[i]<<'\n';
		}		
	}
	return 0;
}

Measured memory_bytes: 7868
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N,W;cin>>N>>W;
    vector<int> v0,v1,v2,v3;
    int z;
    REP(i,N){
        int w,v;cin>>w>>v;
        if(i==0)z=w;
        w-=z;
        if(w==0)v0.pb(v);
        if(w==1)v1.pb(v);
        if(w==2)v2.pb(v);
        if(w==3)v3.pb(v);
    }
    sort(v0.rbegin(),v0.rend());
    sort(v1.rbegin(),v1.rend());
    sort(v2.rbegin(),v2.rend());
    sort(v3.rbegin(),v3.rend());
    vector<int> v0sum(v0.size()+1,0),v1sum(v1.size()+1,0),v2sum(v2.size()+1,0),v3sum(v3.size()+1,0);
    REPS(i,v0.size()){
        v0sum[i]=v0sum[i-1]+v0[i-1];
    }
    REPS(i,v1.size()){
        v1sum[i]=v1sum[i-1]+v1[i-1];
    }
    REPS(i,v2.size()){
        v2sum[i]=v2sum[i-1]+v2[i-1];
    }
    REPS(i,v3.size()){
        v3sum[i]=v3sum[i-1]+v3[i-1];
    }
    int ans=0;
    REP(i,v0.size()+1){
        REP(j,v1.size()+1){
            REP(k,v2.size()+1){
                REP(l,v3.size()+1){
                    if(z*i+(z+1)*j+(z+2)*k+(z+3)*l>W)continue;
                    chmax(ans,v0sum[i]+v1sum[j]+v2sum[k]+v3sum[l]);
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
using namespace std;main(){long MOD=1000000007,N,dp,i;cin>>N;dp=N;vector<long>sum(N+3,(N-1)*N%MOD);sum[0]=0;for(i=3;i!=N+3;++i)sum[i]=(sum[i-1]-1+((dp+=sum[i-3])%=MOD))%MOD;cout<<dp<<endl;}

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

using namespace std;

typedef long long ll;

struct node
{
	ll b, c;
}a[100005];

ll cmp (node x, node y)
{
	return x.c > y.c;
}
ll d[100005], n, m, id;
ll ans;

int main()
{
	cin >> n >> m;
	for(ll i = 1; i <= n; i++)
		cin >> d[i];
	sort(d + 1, d + n + 1);
	for(ll i = 1; i <= m; i++)
		cin >> a[i].b >> a[i].c;
	sort(a + 1, a + m + 1, cmp);
	id = 1;
	for(ll i = 1; i <= n; i++)
	{
		if(d[i] < a[id].c && a[id].b)
		{
			ans += a[id].c;
			a[id].b--;
		}
		else ans += d[i];
		if(a[id].b == 0 && id < m)
		{
			id++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560