akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



int main(){
    string S, T;
    cin >> S >> T;

    int ans = 0;
    rep(i,T.size()){
        if(S[i] != T[i]){
            ans +=1;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long long int a[n],res=0;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	res^=a[i];
	}
	for(int i=0;i<n;i++)
	cout<<(res^a[i])<<" ";	
}


Measured memory_bytes: 5120
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	//cout << max(a*b,c*d) << endl;
	printf((a+b==c||b+c==a||c+a==b) ? "Yes\n" :"No\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N;
	cin>>N;
	int a,c=0;
	for(int i=1;i<=N;i++)
	{
		cin>>a;
		c^=a;
 }
if(c==0)
	cout<<"Yes";
else cout<<"No";




}

Measured memory_bytes: 256
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define mp     make_pair
#define cont   continue
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 1e3  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

char a[MAXN][MAXN];
ll dp[MAXN][MAXN],b[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
ll n,m,k,cnt,sum,ans,mx,mn=INF;
bool y;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}


void solve(){
	cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    dp[1][1]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='.'){
                dp[i][j]+=dp[i-1][j];
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[n][m];
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




Measured memory_bytes: 9216
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N, x;
  cin >> N >> x;
  vector< vector<long long int> > dp(N, vector<long long int>(N,10000000000));
  for(int i = 0; i < N; ++i)
    cin >> dp[0][i];
  long long int ans = 100000000000000000;
  for(int i = 0; i < N; ++i){
    long long int t = (long long int)x*i;
    for(int j = 0; j < N; ++j){
      dp[i][(j+i)%N] = min(dp[max(0,i-1)][(j+i)%N], dp[0][j]);
      t += dp[i][(j+i)%N];
    }
    ans = min(ans, t);
  }
  /*
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < N; ++j)
      cout << dp[i][j] << " ";
    cout << endl;
  }
  cout << endl;
  */
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31616
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll A, B;
	cin >> A >> B;
	if (A % B == 0) cout << -1 << endl;
	else cout << A << endl;
}


Measured memory_bytes: 256
from heapq import heappush, heappop


N, K = map(int, input().split())
A = list(map(int, input().split()))

divs = []
maxA = sum(A)
for i in range(1, int(maxA ** 0.5) + 1):
    if maxA % i == 0:
        heappush(divs, -i)
        j = maxA // i
        if i != j:
            heappush(divs, -j)

while True:
    d = -heappop(divs)
    q = []
    asum = 0
    for a in A:
        rest = a % d
        asum += rest
        heappush(q, -rest)
    cnt = 0
    for i in range(asum // d):
        cnt += d - (-heappop(q))
    if cnt <= K:
        print(d)
        exit()


Measured memory_bytes: 51548
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int cnt;
int func(int x,int y){
    if(x%y == 0)return y;
    ++cnt;
    func(y,x%y);
}
int main(){
    int x,y;
    while(scanf("%d%d",&x,&y),(x|y)){
        cnt = 0;
        if(x < y)swap(x,y);
        int ans = func(x,y);
        printf("%d %d\n",ans,cnt+1);
    }
    return 0;
}

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

int main () {
  string s;
  cin >> s;
  int sunny = 0;
  for(char c : s) sunny += c == 'S';
  if (sunny == 0) cout << 3;
  else if (sunny == 2) cout << 1;
  else if (sunny == 3) cout << 0;
  else {
    if (s[1] == 'S') cout << 1;
    else cout << 2;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp[ohara],tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
unordered_map<ll,ll> mp;
ll imo[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i]>>b[i],tmp[cnt++]=a[i],tmp[cnt++]=b[i];
    sort(tmp,tmp+cnt);
    rep(i,cnt){
        mp[tmp[i]]=tmpp;
        if(tmp[i]!=tmp[i+1])tmpp++;
    }
    rep(i,n){
        imo[mp[a[i]]]++;
        imo[mp[b[i]]+1]--;
    }
    rrep(i,1,ohara){
        imo[i]+=imo[i-1];
    }
    rep(i,ohara){
        ans=max(ans,imo[i]);
    }
    Cout(ans);
    return 0;
}



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

using namespace std;

int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int count=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            count =count+1;
        }
    }
    cout<< count <<endl;
}
    



Measured memory_bytes: 384
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

  
struct Unionfind{
  vi size, par;
  Unionfind(){}
  Unionfind( int n ) :  size(n,1), par(n){
    REP( i , n ) par[i] = i;
  }
  void init( int n ){
    size = vi( n , 1 );
    par.resize( n );
    REP( i , n ) par[i] = i;
  }
  int find( int x ){
    if( par[x] == x ) return x;
    return par[x] = find( par[x] );
  }
  bool unite( int x , int y ){
    x = find(x);
    y = find(y);
    if( x == y ) return false;
    if( size[y] < size[x] ) swap( x , y );
    par[x] = y;
    size[y] += size[x];
    return true;
  }
  bool same( int x , int y ){
    return find(x) == find(y);
  }
};


Unionfind uf;

int n, m;

vi a[100010];

int main(){

  n = in();
  m = in();
  REP( i , n ){
    int k = in();
    REP( j , k ){
      int x = in() - 1;
      a[x].pb( i );
    }
  }

  uf.init( n );
  REP( i , m ){
    REP( j , SZ(a[i])-1 ){
      uf.unite( a[i][j] , a[i][j+1] );
    }
  }

  REP( i , n ){
    if( !uf.same( 0 , i ) ){
      puts( "NO" );
      return 0;
    }
  }

  puts( "YES" );
  

  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<ll> p(N);
    ll count = 0;
    bool sequential = false;
    ll next = 0;
    for(size_t i=0;i<N; i++)
    {
        cin >> p[i];
        if(p[i] == i+1) count++;
        if(i>0 && p[i] == i+1 && p[i-1] == i && !sequential)
        {
            next++;
            sequential = true;
        }else sequential = false;
    }
    cerr << count << ":" << next << endl;
    //隣り合っていたら１回で済むけど離れていたら２回必要
    cout << count - next << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3984
#include "stdio.h"
#include "iostream"
using namespace std;

int main()
{
	long n, a[100001],fournumber=0, evennumber = 0, count = 0;
	cin >> n;
	for (long i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0)
		{
			count++;
			evennumber++;
		}
		if (a[i] % 4 == 0) 
		{
			count++;
			fournumber++;
		}
	}
	if (n <= count || count == n - 1 && evennumber == fournumber)
		cout << "Yes";
	else cout << "No";
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int H,W;
  cin >> H >> W;
  string board[H];
  bool flag;
  rep(i,H) cin >> board[i];

  int dx[] = {1,0,-1,0};
  int dy[] = {0,1,0,-1};
  rep(i,H)rep(j,W){
    if(board[i][j] == '#') {
      //cout << i << " " << j << endl;
      flag = false;
      rep(dir,4){
      if(i + dx[dir] >= 0 && i + dx[dir] < H &&
         j + dy[dir] >= 0 && j + dy[dir] < W    ){
           //cout << board[i+dx[dir]][j+dy[dir]] << endl;
          if(board[i+dx[dir]][j+dy[dir]] == '#') flag = true;
        }
      }
      if(flag == false){
        cout << "No" << endl;
        return 0;
      }

    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(void){
    int N, A[1001], a;
    cin >> N;
    double sum = 0.0;
    for(int i = 0 ; i < N ; i++){
        cin >> a;
        sum += 1.0 / a;
    }
    printf("%8.8f", (1 / sum));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	while(true){
	cin>>a>>b;
	if(a==0 || b==0)break;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cout<<"#";
		}
		cout<<endl;
	}
	cout<<endl;
	}
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#define m 2000001
#define vm 10000

int main(){
	unsigned short *a,*b;
	
	int c[vm+ 1];
	int n,i,j;
	scanf("%d",&n);
	
	a=malloc(sizeof(short)*n +1);
	b=malloc(sizeof(short)*n +1);
	
	for(i=0;i<=vm;i++)c[i]=0;
	
	for(i=0;i<n;i++){
		scanf("%hu",&a[i+1]);
		c[a[i+1]]++;
	}
	
	for(i=1;i<=vm;i++)c[i]=c[i]+c[i-1];
	
	for(j=1;j<=n;j++){
		b[c[a[j]]]=a[j];
		c[a[j]]--;
	}
	
	for(i=1;i<=n;i++){
		if(i>1)printf(" ");
		printf("%d",b[i]);
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 9588
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation​
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 

int main() {
  int N; // 変数の宣言
  cin >> N; // 標準入力
  int K;
  cin >> K;
  int a[N];
  //double sum = 0.0;
  //ll count = 0;
  //vector<int> v;
  rep(i,N){
    cin >> a[i];
  }
  rep(i,N-K){
    if(a[K+i]>a[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  
}

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

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> pic(h);
    rep(i,h) cin >> pic[i];
    rep(i,h) cout << pic[i] << endl << pic[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
  int n,cnt=0;
  cin>>n;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    if(a==b){
      cnt++;
    }else{
      cnt = 0;
    }
    if(cnt == 3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3580
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define ld long double
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    ld s;
    void solve()
    {
        cin>>s;
        cout<<((s/3)*(s/3)*(s/3))<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        deci(10);
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<vector<int>> pref(n, vector<int>(0));
    vector<pair<int, int>> city(m, make_pair(0, 0));
    for (int i = 0; i < m; i++) {
        cin >> city[i].first >> city[i].second;
        pref[city[i].first - 1].push_back(city[i].second);
    }

    for (int i = 0; i < n; i++) {
        sort(pref[i].begin(), pref[i].end());
    }

    for (int i = 0; i < m; i++) {
        cout << setw(6)
            << setfill('0')
            << city[i].first
            << setw(6)
            << setfill('0')
            << (lower_bound(pref[city[i].first - 1].begin(), pref[city[i].first - 1].end(), city[i].second)
                - pref[city[i].first - 1].begin()
                + 1)
            << endl;
    }
}


Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

struct UnionFind{
  VI par;
  VI siz;
  UnionFind(int N):par(N),siz(N){
    rep(i,N){
      par[i]=i;
      siz[i]=1;
    }
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
    siz[ry]=siz[rx]+siz[ry];
  }
  int size(int x){
    return siz[root(x)];
  }
  bool same(int x, int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};

int main(){
  int N,M;
  cin>>N>>M;
  VI K(N);
  VVI L(N,VI());
  int B;
  rep(i,N){
    cin>>K[i];
    rep(j,K[i]){
      cin>>B;
      L[i].pb(B);
    }
  }
  UnionFind uf(N+M);
  rep(i,N) rep(j,K[i]) uf.unite(i,L[i][j]+N-1);
  int X=uf.root(0);
  int ans=1;
  rep(i,N-1) ans*=(X==uf.root(i+1));
  cout<<(ans?"YES":"NO")<<endl;
}

Measured memory_bytes: 7680
# include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    if (n == 1)
        printf("Hello World");
    else
    {
        int a, b;
        scanf("%d", &a);
        scanf("%d", &b);
        printf("%d", a + b);

    }

    return 0;
}

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

const int maxn = 3e5, inf = 3e8;
int n, a[maxn + 3], b[maxn + 3], w[maxn + 3], s[maxn + 3];
bool dp[maxn + 3];

bool check(int x) {
	int mn = 0;
	for (int i = 1; i <= n; i += 2) {
		if (s[i] - mn >= x) {
			dp[i] = true;
			mn = min(mn, s[i + 1]);
		} else {
			dp[i] = false;
		}
	}
	return dp[n];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		b[i] = b[i - 1], w[i] = w[i - 1];
		i & 1 ? b[i] += a[i] : w[i] += a[i];
	}
	for (int i = 1; i <= n; i++) {
		s[i] = b[i] - w[i];
	}
	if (~n & 1) {
		printf("%d %d\n", max(b[n], w[n]), min(b[n], w[n]));
	} else {
		int l = -inf, r = inf, mid;
		while (l < r) {
			mid = ((l + r + inf * 2 + 1) >> 1) - inf;
			if (check(mid)) {
				l = mid;
			} else {
				r = mid - 1;
			}
		}
		int x = max(w[n] + l, b[n]);
		printf("%d %d\n", x, b[n] + w[n] - x);
	}
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b, c;
    cin >> a >> b >> c;

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

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

def path(x, y, gx, gy):
  u = gy - y
  if u > 0:
    for i in range(u):
      print('U', end='')
  elif u < 0:
    for i in range(-u):
      print('D', end='')
  r = gx - x
  if r > 0:
    for i in range(r):
      print('R', end='')
  elif r < 0:
    for i in range(-r):
      print('L', end='')

path(sx,sy,tx,ty)
path(tx,ty,sx,sy)
print('L', end='')
path(sx-1,sy,tx,ty+1)
print('D', end='')
print('R', end='')
path(tx+1,ty,sx,sy-1)
print('U')


Measured memory_bytes: 4468
import math

n = int(input())
lst = list(map(float, input().split()))

dp = [[0] * (n+1) for _ in range(n+1)] #行は表の枚数、列は試行回数
dp[0][0] = 1
for i in range(0, n):
    for j in range(0, n):
        dp[i+1][j+1] += dp[i][j] * lst[i] #表のとき
        dp[i+1][j] += dp[i][j] * (1 - lst[i]) #裏のとき
        
hlf = math.ceil(n/2)
ansl = dp[n][hlf:n+1]
ans = sum(ansl)
print(ans)

Measured memory_bytes: 203064
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <cassert>
using namespace std;

class Point {
public:
  int x, y;
  Point() {}
  Point(int x, int y): x(x), y(y) {}

  bool operator==(const Point &other) const {
    return this->x == other.x && this->y == other.y;
  }

  static bool cmp_x(Point p, Point q) {
    return p.x < q.x;
  }

  static bool cmp_y(Point p, Point q) {
    return p.y < q.y;
  }
};

class UnionFind {
  struct Hash {
    size_t operator()(const Point &key) const {
      return hash<int>()((key.x + 1) * (key.y + 1));
    }
  };

  unordered_map<Point, Point, Hash> parent;
  unordered_map<Point, int, Hash> rank;

public:

  Point root(Point x) {
    if (parent.find(x) == parent.end()) {
      parent[x] = x;
      rank[x] = 1;
      return x;
    }
    return parent[x] == x ? x : parent[x] = root(parent[x]);
  }

  bool is_same(Point x, Point y) {
    return root(x) == root(y);
  }

  void unite(Point x, Point y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    parent[y] = x;
  }
};

class UndirectedGraph {
  class Edge {
  public:
    pair<Point, Point> vertex;
    int cost;

    Edge(Point i, Point j, int cost):
      vertex(make_pair(i, j)),
      cost(cost)
    {}

    bool operator<(const Edge &other) const {
      return this->cost < other.cost;
    }
  };

  vector<Edge> edges;

public:
  void connect(Point i, Point j, int cost) {
    edges.push_back(Edge(i, j, cost));
  }

  int kluskal() {
    sort(edges.begin(), edges.end());
    UnionFind uf;
    int res = 0;
    for (Edge e : edges) {
      pair<Point, Point> p = e.vertex;
      Point u = p.first; Point v = p.second;
      if (!uf.is_same(u, v)) {
        uf.unite(u, v);
        res += e.cost;
      }
    }
    return res;
  }
};

int main() {
  UndirectedGraph g;
  int n; cin >> n;
  vector<Point> ps(n), qs(n);
  for (int i = 0; i < n; ++i) {
    int x, y; cin >> x >> y;
    ps[i] = qs[i] = Point(x, y);
  }
  sort(ps.begin(), ps.end(), Point::cmp_x);
  sort(qs.begin(), qs.end(), Point::cmp_y);
  for (int i = 0; i < n - 1; ++i) {
    g.connect(ps[i], ps[i + 1], ps[i + 1].x - ps[i].x);
    g.connect(qs[i], qs[i + 1], qs[i + 1].y - qs[i].y);
  }
  cout << g.kluskal() << endl;
}

Measured memory_bytes: 18156
#include<stdio.h>
int main(void){
    int n, m=0, c=-1;
    int l=0;
    int a[200000];
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        if(m<a[i]){
            m=a[i];
            c=i;
        }
    }
    a[c]=0;
    for(int i=0; i<n; i++){
        if(l<a[i]){
            l=a[i];
        }
    }
    for(int i=0; i<n; i++){
        if(i!=c){
            printf("%d\n", m);
        }else{
            printf("%d\n", l);
        }
    }
    return 0;
}

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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int main()
{
	Fastest
	
    int n, k;
    string ch;
    
    cin >> n >> k;
    
    cin >> ch;
    
    int coun[100005];
    
    if(ch[0] == 'A' && ch[1] == 'C') 
    {
		coun[1] = 0;
		coun[2] = 1;
	}
	
	for(int i = 2; i < n-1; i++)
	{
		if(ch[i] == 'A' && ch[i+1] == 'C')
		{
			
			coun[i+1] = coun[i];
			coun[i+2] = coun[i] + 1;
			i++;
		}
		else
		{
			coun[i+1] = coun[i];
		}
	}
	
	if(!(ch[n-2] == 'A' && ch[n-1] == 'C'))
	{
		coun[n] = coun[n-1];
	}
	
	//for(int i = 1; i <= n; i++) cout << coun[i] << " ";
	//cout << endl;
	
	int a, b;
	
	for(int i = 1; i <= k; i++)
	{
		cin >> a >> b;
		
		cout << coun[b]-coun[a] << endl;
	}
	
	return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> vec(N);
  vector<int64_t> H(N);
  for (int i=0; i<N; i++) cin >> H.at(i);
  for (int i=0; i<M; i++){
	int A, B;
    cin >> A >> B;
    if (H.at(A-1) <= H.at(B-1)) vec.at(A-1) = true;
    if (H.at(A-1) >= H.at(B-1)) vec.at(B-1) = true;
  }
  int count = 0;
  for (int i=0; i<N; i++){
    if (!(vec.at(i))) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 4060
// Problem : C - Subarray Sum
// Contest : AtCoder - Keyence Programming Contest 2020
// URL : https://atcoder.jp/contests/keyence2020/tasks/keyence2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k, s;
	cin >> n >> k >> s;
	REP(i, k) {
		cout << s << " ";
	}
	FOR(i, k, n - 1) {
		if (s == 1e9) cout << 1 << " ";
		else cout << s + 1 << " ";
	}
	return 0;
}
 


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

set<ll> st;

void dfs(ll x) {
    if (st.find(x) != st.end()) {
        return;
    }
    st.insert(x);

    int nd = 0;
    ll x_tmp = x;
    while (x_tmp > 0) {
        ++nd;
        x_tmp /= 10;
    }
    if (nd >= 11) return;

    int l = x % 10;
    if (l == 9) {
        dfs(10 * x + l - 1);
        dfs(10 * x + l);
    }
    else if (l == 0) {
        dfs(10 * x + l);
        dfs(10 * x + l + 1);
    }
    else {
        dfs(10 * x + l - 1);
        dfs(10 * x + l);
        dfs(10 * x + l + 1);
    }
}

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int K;
    cin >> K;

    for (int i = 1; i <= 9; i++) {
        dfs(i);
    }

    cout << *next(st.begin(), K - 1) << endl;

    return 0;
}


Measured memory_bytes: 30860
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  map<ll,ll> mp;
  for(ll i = 1;i <= 100; i++){
    for(ll j = 1;j <= 100; j++){
      for(ll k = 1;k <= 100; k++){
        mp[i*i+j*j+k*k+i*j+j*k+k*i]++;
      }
    }
  }
  ll N; cin >> N;
  rep(i,N){
    cout << mp[i+1] << endl;
  }
}

Measured memory_bytes: 6064
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int kazu[200], i = 0;
	char siki[200];

	while (scanf("%s", siki) != EOF) {
		switch (siki[0]) {
		case '+':
			kazu[i - 2] += kazu[i - 1];
			i--;
			break;
		case '-':
			kazu[i - 2] -= kazu[i - 1];
			i--;
			break;
		case '*':
			kazu[i - 2] *= kazu[i - 1];
			i--;
			break;
		default:
			kazu[i] = atoi(siki);
			i++;
			break;
		}
	}

	printf("%d\n", kazu[0]);
	scanf("%s", siki);
	return 0;
}

Measured memory_bytes: 548
#include<stdio.h>
#include<stdlib.h>
int main(){
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    
    int K = abs(A+B) / 2;
    if((A + B) % 2 == 0){
        printf("%d",K);
    }else{
        printf("IMPOSSIBLE");
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define N 1000000 /* Q's length */

/* P's member */
typedef struct{
  char name[100];
  int t;
}P;

P Q[N]; /* make Q */
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail++;
}

P dequeue(){
  P x = Q[head];
  head++;
  return x;
}

/* small number return */
int mini(int x, int y){
  if(x < y) return x;
  else return y;
}

int main()
{
  /* time0 -> tortal time, time1 -> used time */
  int i, q, time0=0, time1;
  P s;

  scanf("%d%d", &n, &q);
  for(i = 1; i <= n; i++) scanf("%s%d", Q[i].name, &Q[i].t); /* add member in Q */
  head = 1;
  tail = n+1;

  while(head != tail){
    s = dequeue();
    time1 = mini(q, s.t); /* used time -> q or s.t */
    s.t -= time1;
    time0 += time1; /* add time */
    if(s.t > 0) enqueue(s);
    else printf("%s %d\n", s.name, time0);
  }

  return 0;
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=100009;
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n,k,ans=0;
	cin >> n >> k;
	int a[n+1]={0};
	for(int i=1;i<=n;i++)
		cin >> a[i];
	for(int i=1;i<=n;i++)
		a[i]+=a[i-1];
	for(int i=k;i<=n;i++)
		ans=max(ans,a[i]-a[i-k]);
	ans+=k;
	if(ans%2)cout << ans/2 << ".5";
	else cout << ans/2;	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<ll> vec(5);
    rep(i,5)cin >> vec[i];
    ll ans = INF;
    do{
        ll cnt = 0;
        rep(i,4){
            cnt += vec[i];
            if(cnt % 10 != 0)cnt = (cnt / 10 + 1) * 10;
        }
        cnt += vec[4];
        chmin(ans,cnt);
    }while(next_permutation(all(vec)));
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
#include <cstdint>
#include <cstring>

using namespace std;


//#define DEBUG


int main()
{
	long long int A, B;
	cin >> A;
	cin >> B;

#ifdef DEBUG
	cout << A << "," << B << endl;
#endif
	long long int count = 1;
	long long int tmp = A;

	while (true){
		if (tmp >= B){
			break;
		}
		else{
			tmp = tmp + A - 1;
			count++;
		}
	}

#ifdef DEBUG
	cout << B << "," << tmp << endl;
#endif

	if (B==1){
		count = 0;
	}

	cout << count << endl;

#ifdef DEBUG
	system("pause");
#endif

	return 0;
}

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

int main(){
  string a,b;
  int num;
  cin >> a >> b;
  a += b;
  num = stoi(a);
  for(int i = 1;i<=10000;i++){
    if(num == i * i){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

double rec(int K, double L, double R, double P, double E, double T){
  if(L >= T - E && R < T + E) return 1;
  if(R <= T - E || L > T + E) return 0;

  double H = (L+R)/2;

  if(K == 0){
    if(H >= T - E && H <= T + E) return 1;
    else return 0;
  }

  if(H >= T){
    return P*rec(K-1,H,R,P,E,T) + (1-P)*rec(K-1,L,H,P,E,T);
  }else{
    return P*rec(K-1,L,H,P,E,T) + (1-P)*rec(K-1,H,R,P,E,T);
  }
}

int main(){
  int K;
  double R, L, P, E, T;
  cin >> K >> R >> L >> P >> E >> T;
  printf("%.12f\n",rec(K,R,L,P,E,T));
  return 0;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
int n,k,a[200010];
signed main()
{
	;;;;;
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=k+1;i<=n;i++)
	{
		if (a[i]>a[i-k]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 4412
#include <iostream>
#include <vector>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999
using namespace std;

int main(){
          char s[3];
          cin >> s;
          if (s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0])     cout << "Yes" << endl;
          else cout << "No" << endl;
          return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;
const int inf = TEN(18) * 3 + 10;

const int B = mod;

string S;
int dp[100010][4];

signed main()
{
	cin >> S;
	int n = S.size();

	S = ' ' + S;

	dp[0][0] = 1;

	rep1(i, n) {
		if (S[i] == '?') {
			rep(j, 3) {
				(dp[i][j + 1] += dp[i - 1][j]) %= mod;
			}
			rep(j, 4) (dp[i][j] += dp[i - 1][j] * 3) %= mod;
		} else {
			rep(j, 4) (dp[i][j] += dp[i - 1][j]) %= mod;
			if (S[i] == 'A') {
				(dp[i][1] += dp[i - 1][0]) %= mod;
			}
			if (S[i] == 'B') {
				(dp[i][2] += dp[i - 1][1]) %= mod;
			}
			if (S[i] == 'C') {
				(dp[i][3] += dp[i - 1][2]) %= mod;
			}
		}
	}

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



Measured memory_bytes: 3580
import numpy as np
import math

a,b,h,m = map(int,input().split())

k_h = 360*(h/12)+30*(m/60)
k_m = 360*(m/60)

k = abs(k_h-k_m)
if k >= 180:
  k = 360 - k

cos = math.cos(math.radians(k))
res = np.sqrt(a**2+b**2-2*a*b*cos)
print(res)

Measured memory_bytes: 27148
m, f, r = map(int, input().split())
while not (m == -1 and f == -1 and r == -1):
    if m == -1 or f == -1:
        g = "F"
    elif m + f >= 80:
        g = "A"
    elif m + f >= 65:
        g = "B"
    elif m + f >= 50:
        g = "C"
    elif m + f >= 30:
        if r >= 50:
            g = "C"
        else:
            g = "D"
    else:
        g = "F";
    print(g)
    m, f, r = map(int, input().split())


Measured memory_bytes: 5596
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let a: Vec<u32> = parse_line().unwrap();

    let odd = a.iter().filter(|&x| x % 2 == 1).count();
    let quad = a.iter().filter(|&x| x % 4 == 0).count();
    if quad >= n / 2 {
        println!("Yes");
    } else if odd <= quad {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 3428
n, m = [int(i) for i in input().split()]
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
cnt = 0
for i in range(2**n):
  on = set(j + 1 for j in range(n) if i >> j & 1 == 1)
  flag = True
  for j in range(m):
    _, *s = ks[j]
    flag &= len(on & set(s)) % 2 == p[j]
  cnt += flag
print(cnt)


Measured memory_bytes: 9200
#include<iostream>
using namespace std;
int main()
{
  int c[3],s;
  for(;cin>>c[0]>>c[1]>>c[2];)
    {
      int l[11]={0};
      int co=0,sum=0;
      for(int i=0;i<2;i++)
	l[c[i]]=1;
      s=c[0]+c[1];
      for(int i=1;i<11;i++)
	{
	  if(l[i]==0)
	    {
	      if(s+i<21)
		co++;
	      sum++;
	    }
	}
      if(0.5>(double)co/sum)
	cout<<"NO"<<endl;
      else
	cout<<"YES"<<endl;
    }
}

Measured memory_bytes: 1152
import sys,queue,math,copy,itertools,bisect,collections
from heapq import *

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,M = LI()
    root =[[] for _ in range(N+1)]
    for _ in range(M):
        a,b = LI()
        root[a].append(b)
        root[b].append(a)

    node = [INF] * (N+1)
    ans = [-1] * (N+1)

    q = collections.deque()
    node[1] = 0
    q.append((0,1,-1))

    while q:
        d,v,f = q.popleft()
        node[v] = d
        ans[v] = f
        for u in root[v]:
            if node[u] <= d+1: continue
            node[u] = d+1
            q.append((d+1,u,v))

    print('Yes')
    print(*ans[2:],sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 105160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a[100005],ans=0,x;
    cin>>n;
    for(int i=0;i<100005;i++)a[i]=0;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x>n)ans++;
        else a[x]++;
    }
    for(int i=0;i<=n;i++){
        if(a[i]<i)ans+=a[i];
        else ans+=a[i]-i;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        String ans = "No";
        if(N%500<=A) ans = "Yes";
        System.out.println(ans);


    }
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int base_line = 0;
    for(int i = 0; i < n - 1; i++){
        
        if(a[i] > a[i+1]){
            base_line = max(base_line, a[i] - 1);
            if((a[i] - 1 > a[i+1]) || base_line > a[i+1]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
  int r, g, b;
  cin >> r >> g >> b;

  int a = 100 * r + 10 * g + b;
  cout << (a % 4 == 0 ? "YES" : "NO") << endl;
  
  return 0;
}


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


int main(void) {
	int S = 0;
	int K = 0;

	cin >> S;

	if (400 <= S && S <= 599)
		cout << 8;
	else if (600 <= S && S <= 799)
		cout << 7;
	else if (800 <= S && S <= 999)
		cout << 6;
	else if (1000 <= S && S <= 1199)
		cout << 5;
	else if (1200 <= S && S <= 1399)
		cout << 4;
	else if (1400 <= S && S <= 1599)
		cout << 3;
	else if (1600 <= S && S <= 1799)
		cout << 2;
	else if (1800 <= S && S <= 1999)
		cout << 1;

}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

long long modpow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

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

	int N;
	int C[62] = { 0 };

	cin >> N;
	int A;
	rep(i, 0, N)
	{
		cin >> A;
		rep(j, 0, 62)
		{
			if ((A >> j) & 1)C[j]++;
		}
	}

	int ans = 0;
	rep(i, 0, 62)
	{
		ans = (ans + ((C[i] * (N - C[i])) % MOD)*modpow(2, i)) % MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b; cin >> a >> b;
  string s = to_string(a) + to_string(b);

  int t = stoi(s);
  int x = sqrt(t);

  if (x * x == t) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


Measured memory_bytes: 3756
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=2e5+5;
int n,k,a[N],st[N],last[N],nxt[N],rd=1,ed[N];
vector<int> roll;

signed main(){
	read(n,k);
	for(int i=1;i<=n;i++) read(a[i]),st[a[i]]?1:st[a[i]]=i;
	for(int i=n;i;i--) nxt[i]=last[a[i]]?last[a[i]]:st[a[i]],last[a[i]]=i;
	for(int x=1;x<=n;x=nxt[x]+1) ed[rd]=roll.size(),roll.push_back(x),nxt[x]<=x?++rd:1;
	ed[rd]=roll.size();
	roll.push_back(n+1);
	k%=rd;if(!k) k=rd;ed[0]=-1;
//	for(int i=1;i<=rd;i++){
//		putchar('#');
//		for(int j=ed[i-1]+1;j<=ed[i];j++) write(roll[j]),putchar(' ');
//		puts("");
//	}
//	printf("@%lld %lld\n",roll[ed[k]],nxt[roll[ed[k]]]);
	for(int i=1;i<=n;i++) last[a[i]]=nxt[a[i]]=0;
	for(int i=n;i>=roll[ed[k]];i--) nxt[i]=last[a[i]]?last[a[i]]+1:i+1,last[a[i]]=i;
	for(int i=roll[ed[k]],j;i<=n;i=j+1){
		j=i;
		while(nxt[j]!=j+1&&j<=n) j=nxt[j];
		if(j>n) break;
		write(a[j]);putchar(' ');
	}
}

Measured memory_bytes: 12692