akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    ll i,q,qt,f,beg=0;
    vector<char> start,end;
    char c;
    cin >> s;
    cin >> q;
    while(q--) {
    	cin >> qt;
    	if(qt == 1) {
    		beg = 1-beg;
    	} else {
    		cin >> f >> c;
    		if(f == 1) {
    			if(!beg) start.pb(c);
    			else end.pb(c);
    		} else {
    			if(!beg) end.pb(c);
    			else start.pb(c);
    		}
    		//cout << s << "\n";
    	}
    }
    string temp="";
    for(i=0;i<start.size();i++) temp=start[i]+temp;
    s = temp+s;
	temp="";
    for(i=0;i<end.size();i++) temp = temp+end[i];
    s=s+temp;
    if(beg) {
    	reverse(s.begin(), s.end());
    }
    cout << s;
    cout << "\n";
    return 0;
}



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

int main() {
  int N = 0;
  
  cin >> N;
  
  if ((N % 10 == N / 10 % 10)&&(N / 10 % 10 == N / 100 % 10)) {
    cout << "Yes" << endl;
  }
  else if ((N / 10 % 10 == N / 100 % 10)&&(N / 100 % 10 == N / 1000)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
#define PB push_back 
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<int>())
#define F first 
#define S second
 
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln
 
#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6
 
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
 
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
void solve() { 
    string s;
    in1(s);
    if(s=="ARC") out1("ABC");
    else out1("ARC");
}
 
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    zoom;
    
    // ll t;
    // in1(t);
    // while(t--) {
        solve();
    // }
 
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c;
int i[1000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>s;
  int ans=0;
  int oo=0;
  bool can=false;
  for(int n=0;n<s.size();n++){
      if(!can&&s[n]=='A') can=true;
      if(can){
	  ans++;
	  if(s[n]=='Z') oo=max(oo,ans);
      }
  }
  cout <<oo<<'\n';
  return (0);
}


Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int N,S,W,Q;

int a[100000];

void solve(){

	unsigned int res=0;
	map<int,int> M;
	M.clear();

    int g = S;
    for(int i=0; i<N; i++) {
        a[i] = (g/7) % 10;
        if( g%2 == 0 ) { g = (g/2); }
        else           { g = (g/2) ^ W; }
    }

	if(Q==2 || Q==5){
		int count=0;
		for(int i=N-1;i>=0;i--){
			if(a[i]%Q==0)
				count++;
			if(a[i]!=0)
				res+=count;
		}
		cout<<res<<endl; return;
	}


	res=0;
	int mul=1;
	int bef=0;


	for(int i=N-1;i>=0;i--){
		bef=(a[i]*mul+bef)%Q;
		if(!M.count(bef)) M[bef]=1;
		else
			M[bef]++;
		
		if(a[i]!=0) res+=M[bef]-(bef!=0);
		mul=(10*mul)%Q;
	}
	cout<<res<<endl;
}

int main(){

	while(cin>>N>>S>>W>>Q){
		if(N==0 && S==0 && W==0 && Q==0) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,m;
int mul(int a,int b){
	return (LL)a*b%m;
}
int sqr(int a){
	return mul(a,a);
}
int ksm(int a,int b){
	return b==0?1:mul(sqr(ksm(a,b>>1)),b&1?a:1);
}
int inv(int a){
	return ksm(a,m-2);
}
const int N=6060;
int i2[N]={1};
int i6[N]={1};
int x2[N]={1};
int fr[N]={1};
int ifr[N]={1};
int main(){
	scanf("%d%d",&n,&m);
	i2[1]=inv(2);
	for(int i=2;i<N;i++){
		i2[i]=mul(i2[i-1],i2[1]);
	}
	i6[1]=inv(6);
	for(int i=2;i<N;i++){
		i6[i]=mul(i6[i-1],i6[1]);
	}
	x2[1]=2;
	for(int i=2;i<N;i++){
		x2[i]=mul(x2[i-1],x2[1]);
	}
	for(int i=1;i<N;i++){
		fr[i]=mul(fr[i-1],i);
		ifr[i]=inv(fr[i]);
	}
	int ans=0;
	for(int i=0;3*i<=3*n;i++){
		for(int j=0;3*i+2*j<=3*n&&i+j<=n;j++){
			int k=3*n-3*i-2*j;
			// cerr<<i<<" "<<j<<endl;
			ans=(ans+mul(mul(mul(fr[3*n],ifr[i]),mul(ifr[j],ifr[k])),mul(mul(i2[j],i6[i]),x2[i])))%m;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main() {
    int cnt1,cnt2;
    cnt1 = cnt2 = 0;
    int x;
    for(int i = 1; i <= 3; ++i) {
        cin >> x;
        if(x == 5) cnt1++;
        else if(x == 7) cnt2++;
    }
    if(cnt1 == 2 && cnt2 == 1) {
        cout << "YES\n";
    } else cout << "NO\n";
return 0;
}

Measured memory_bytes: 3596
code = """

# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False

from libcpp.string cimport string
from libc.stdio cimport getchar, printf
from libcpp.vector cimport vector
cpdef inline vector[int] ReadInt(int n):
    cdef int b, c
    cdef vector[int] *v = new vector[int]()
    for i in range(n):
        c = 0
        while 1:
            b = getchar() - 48
            if b < 0: break
            c = c * 10 + b
        v.push_back(c)
    return v[0]

cpdef inline vector[string] Read(int n):
    cdef char c
    cdef vector[string] *vs = new vector[string]()
    cdef string *s
    for i in range(n):
        s = new string()
        while 1:
            c = getchar()
            if c<=32: break
            s.push_back(c)
        vs.push_back(s[0])
    return vs[0]

cpdef inline void PrintLongN(vector[long] l, int n):
    for i in range(n): printf("%ld\\n", l[i])

cpdef inline void PrintLong(vector[long] l, int n):
    for i in range(n): printf("%ld ", l[i])
cdef extern from *:
    ctypedef long long ll "long long"

cdef extern from "<atcoder/string>" namespace "atcoder":
    vector[int] lcp_array(string s, vector[int] sa)
    vector[int] lcp_array[ll](vector[ll] s, vector[int] sa)

def LcpArray(s, sa):
    return lcp_array(s, sa)

cpdef vector[int] LcpArrayNum(vector[ll] s, vector[int] sa):
    return lcp_array(s, sa)
cdef extern from *:
    ctypedef long long ll "long long"

cdef extern from "<atcoder/string>" namespace "atcoder":
    vector[int] suffix_array(string s)
    vector[int] suffix_array[ll](vector[ll] s)
    vector[int] suffix_array(vector[int] s, int upper)

def SuffixArray(s):
    return suffix_array(s)

cpdef vector[int] SuffixArrayNum(vector[ll] s):
    return suffix_array(s)

cpdef vector[int] SuffixArrayNumUp(vector[int] s, int upper):
    return suffix_array(s, upper)
"""


import os, sys, getpass

if sys.argv[-1] == 'ONLINE_JUDGE':
    code = code.replace("USERNAME", getpass.getuser())
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
    sys.exit(0)


from atcoder import Read, SuffixArray, LcpArray

def main():
    S = Read(1)[0]
    sa = SuffixArray(S)
    ans = (len(S) * (len(S)+1))//2
    for x in LcpArray(S, sa):
        ans -= x
    print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 59804
def gcm(a,b):
    if a < b:
        a,b = b,a
    if b == 1:
        return 1
    if b == 0:
        return a
    return gcm(b,a%b)

a,b = (int(num) for num in input().split())
print(a*b // gcm(a,b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vll A(N), F(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(ALL(A));
  for(int i = 0; i < N; i++){
    cin >> F.at(i);
  }
  sort(ALL(F), greater<ll>());
  ll ok = INF;
  ll ng = -1LL;
  while(ok - ng > 1){
    ll mid = (ok+ng)/2LL;
    ll counter = 0LL;
    for(int i = 0; i < N; i++){
      if(A.at(i) * F.at(i) <= mid) continue;
      ll target = mid / F.at(i);
      counter += A.at(i) - target;
    }
    if(counter <= K) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 3328
#include <deque>
#include <cstdio>

using namespace std;

int main(){
    deque<int> dq;
    int n, q, d, x;
    scanf("%d", &n);
    for(int i = 0; i<n; i++){
        scanf("%d", &q);
        scanf("%d", &d);
        if(q==0){
            scanf("%d", &x);
            if(d==0){
                dq.push_front(x);
            }else{
                dq.push_back(x);
            }
        }else if(q==1){
            printf("%d\n", dq.at(d));
        }else{
            if(d==0){
                dq.pop_front();
            }else{
                dq.pop_back();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4156
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    stack<char> stk;
    rep(i,s.size()){
        if(s[i] == '0') stk.push('0');
        if(s[i] == '1') stk.push('1');
        if(s[i] == 'B'){
            if(!stk.empty()) stk.pop();
        }
    }
    string ans = "";
    while(!stk.empty()){
        ans += stk.top();
        stk.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

    int n;
    ll m;
    cin >> n >> m;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);

    int l = 1, r = 2e5+1;
    while (r - l > 1) {
        int mid = (l + r) / 2;

        ll cur = 0;
        for (int i = 0, j = n - 1; i < n; i++) {
            while (j >= 0 && a[i] + a[j] >= mid) {
                j--;
            }
            cur += n - 1 - j;
        }

        if (cur >= m) {
            l = mid;
        } else {
            r = mid;
        }
    }

    ll ss[n+1];
    for (int i = n; i >= 0; i--) {
        ss[i] = i == n ? 0 : ss[i+1] + a[i];
    }

    ll ans = 0, cnt = 0;
    for (int i = 0, j = n - 1; i < n; i++) {
        while (j >= 0 && a[i] + a[j] >= r) {
            j--;
        }

        cnt += n - 1 - j;
        ans += 1ll * (n - 1 - j) * a[i] + ss[j+1];
    }

    ans += l * (m - cnt);

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1e9  //
#define LINF 1e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//------------------------------------------------------

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

    if (a + b > c + d) {
        cout << "Left" << endl;
    } else if (a + b < c + d) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }

    return 0;
}



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

#define fer( a , b , c ) for( register int a = b ; a <= c ; a ++ )
#define der( a , b , c ) for( register int a = b ; a >= c ; a -- )

  using namespace std ;

inline int read(){
	int sum = 0 , f = 1 ;
	char ch = getchar() ;
	while( ch < '0' || ch > '9' ){
		if( ch == '-' ){
			f = -1 ;
		}
		ch = getchar() ;
	}
	while( ch >= '0' && ch <= '9' ){
		sum = ( sum << 1 ) + ( sum << 3 ) + ( ch ^ 48 ) ;
		ch = getchar() ;
	}
	return sum * f ;
}

char a[ 10005 ] ;

signed main(){
    scanf( "%s" ,&a ) ;
    register int len = strlen( a ) ;
    if( a[ len - 1 ]  == 's' ) printf( "%ses" , a ) ;
    else printf( "%ss" , a ) ;
	return 0 ;
}

Measured memory_bytes: 3828
N = int(input())
X = []
Y = []
Height =[] 
for i in range(N):
    x,y,h = map(int,input().split())
    X.append(x)
    Y.append(y)
    Height.append(h)
List = []
flag = 0
for i in range(N):
    if flag ==1:
        break
    if Height[i]==0:
        continue
    else:
        for Cx in range(101):
            for Cy in range(101):
                tmp_h = Height[i]+abs((X[i]-Cx))+abs((Y[i]-Cy))
                if tmp_h >= 1 :
                    List.append([Cx,Cy,tmp_h])
        flag = 1
     
    #1個目のx,y,hからCx,Cy,Hの候補を作り(List)，他のx,y,hは候補と照らし合わせながら答えを探す．
    #制約が小さいからできる全探索

for i in range(1,N):
    for j in List[:]:
        if Height[i] == max(j[2]-abs((X[i]-j[0]))-abs((Y[i]-j[1])),0):
            continue
        else:
            List.remove(j)

print(List[-1][0],List[-1][1],List[-1][2])

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int a,b,k;
  cin >> a >> b >> k;
  for(int i=a;i<=b;i++){
    if(a+k<=i&&i<=b-k){
      continue;
    }
    cout << i << endl;
  }
}

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

int main() {
    int m; cin >> m;
    long long u = 0;
    long long d = 0;
    for (int i = 0; i < m; i++) {
        long long a, b; cin >> a >> b;
        d += b;
        u += a * b;
    }
    cout << (d-1) + u / 9 - (u % 9 == 0) << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll n, k;
bool check(vector<ll> &a, vector<ll> &f, ll mid){
	ll cou = 0;
	REP(i, n){
		ll tmp = mid / f[i];
		cou += max(0LL, a[i] - tmp);
	}

	return cou <= k;
}

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

	cin >> n >> k;
	vector<ll> a(n);REP(i, n)cin >> a[i];
	vector<ll> f(n);REP(i, n)cin >> f[i];
	sort(ALL(a));
	sort(ALL(f), greater<ll>());

	ll l = -1;
	ll r = LLINF;

	while(r - l > 1){
		ll mid = (l + r) / 2;
		if(check(a, f, mid))r = mid;
		else l = mid;
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>

int main(){
	int arg[50], tmp[50];
	int i, j, n, r, p, c, k, index, front=0;

	scanf("%d %d", &n, &r);
	while(n!=0 && r!=0){
		for(i=0; i<n; i++) {
			arg[n-1-i]=i+1;
		}
		for(i=0; i<r; i++) {
			scanf("%d %d",&p ,&c);
			index=p;
			front=0;
			for(j=0; j<c; j++) {
				tmp[j] = arg[p-1];
				p++;
			}
			for(j=index-2; j>=0; j--) {
				arg[j+c] = arg[j];
			}

			for(j=0; j<c; j++) {
				arg[front] = tmp[j];
				front++;
			}
		}
		printf("%d\n",arg[0]);
		scanf("%d %d",&n ,&r);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=500+10;
ll A[maxn][maxn];
int main(){
	int H=read(),W=read(),h=read(),w=read();
	if(H%h==0 && W%w==0) return printf("No\n"),0;
	int V=2000;
	A[0][0]=V*(h*w-1)-1;
	REP(i,0,h-1) REP(j,0,w-1) if(i || j) A[i][j]=-V;
	printf("Yes\n");
	REP(i,0,H-1) REP(j,0,W-1) printf("%d%c",A[i%h][j%w],j==jend?'\n':' ');
	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;

typedef vector<ld> vec;
typedef vector<vec> mat;
void debag_matrix(const mat &A) {
	rep(i, A.size()) {
		rep(j, A[i].size()){
			cout << A[i][j] << " ";
	    }
		cout << endl;
	}
}
void gauss_hakidasi(mat &A) {
	int n = A.size(), m = A[0].size();
	int t = min(n, m);
	rep(k, t) {
		int chk = -1;
		Rep(i,k, n) {
			if (abs(A[i][k]) > eps) {
				chk = i; break;
			}
		}
		if (chk < 0)return;
		swap(A[k], A[chk]);
		ld x = A[k][k];
		rep(i, m) {
			A[k][i] /= x;
		}
		rep(i, n) {
			if (i == k)continue;
			x = A[i][k];
			rep(j, m) {
				A[i][j] -= x * A[k][j];
			}
		}
	}
}
int n;
ld d[10];

bool valid(int id, mat A) {
	gauss_hakidasi(A);
	//debag_matrix(A);
	ld sum = 0;
	ld cur = 1;
	per(i, n + 1) {
		sum += A[i][n+1] * cur; cur *= id;
	}
	return abs(sum - d[id]) < eps;
}
int main() {
	while (cin >> n, n) {
		rep(i, n + 3)cin >> d[i];
		rep(i, n + 3) {
			mat A; int ck = 0;
			per(j, n + 3) {
				if (i == j)continue;
				vector<ld> v;
				ld cur = 1;
				rep(k, n + 1) {
					v.push_back(cur);
					cur *= j;
				}
				reverse(v.begin(), v.end());
				v.push_back(d[j]);
				if (A.size() < n + 1)A.push_back(v);
				else ck = j;
			}
			//debag_matrix(A);
			//cout << ck << endl;
			if (valid(ck, A)) {
				cout << i << endl; break;
			}

		}
		//cout << "finish" << endl;
	}
	//stop
	return 0;
}



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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//--------------------------------------------------------------------------

int main()
{
    string s,t ; cin>>s>>t;
    vi v;
    for(int i=0; i<=s.sz-1-(t.sz-1); i++){
        string tem = s.substr(i,t.sz);
        int c=0;
        for0(i,t.sz){
            if(tem[i]==t[i]) c++;
        }
        v.pb(c);
    }
    cout<<t.sz - *max_element(all(v));
}


Measured memory_bytes: 3612
i,m;main(h,s,B){for(B=60;++i%2?scanf("%d%d%d",&h,&m,&s),h=(120-h*B-m)*B-s,m=~m:1;h*=3)printf("%02d:%02d:%02d\n",h/B/B,h/B%B,h%B);}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long M = 1e9+7;
long long power(long long a, long long p)
    {
        if(p==0) return 1;
        long long ans= power(a,p/2);
        ans =(ans * ans) % M;
        if(p%2) ans = (ans*a) % M;
        return ans;
    }

    bool isPrime(long long n)
    {
        if (n <= 1)
            return false;
        for (long long i = 2; i < n; i++)
            if (n % i == 0)
                return false;
        return true;
    }
    long long SieveOfEratosthenes(long long n, long long a)
    {
        bool prime[n+1];
        memset(prime, true, sizeof(prime));
        for (long long p=2; p*p<=n; p++)
        {
            if (prime[p] == true)
            {
                for (long long i=p*p; i<=n; i += p)
                    prime[i] = false;
            }
        }
        for (long long p=2; p<=n; p++)
           if (prime[p])
           {
               if(a%p==0)
               {
                   return (a-p);
               }
           }
    }
    long long nCr(int n, int r)
    {
        if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
        long long ans = 1;
        int i;
        for(i = 1; i <= r; i++) {
            ans *= n - r + i;
            ans /= i;
        }
        return ans;
    }
int main()
{
    IOS;
    long long a,b,c,d,e,h,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
    // vector<string>vs;
    // vector<string>vs1;
    vector<char>vc;
    //map<long long,long long>mp;
    map<char,int>mp1;
    //set<long long>s;
    set<long long>s1;
    queue<long long> q;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
    // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    int x[]={1,1,1,0,0,-1,-1,-1};
    int y[]={0,1,-1,1,-1,1,-1,0};
    cin>>str;
    for(int i=0; i<str.size(); i++)
    {
        if(str[i]=='+') sum++;
        else sum--;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
flg = True
i = 0
while i <= (N-3)/2:
    if S[i]!=S[int((N-3)/2-i)]:
        flg = False
    i += 1
i = N-1
while i >= (N+1)/2:
    if S[i]!=S[int((3*N-1)/2-i)]:
        flg = False
    i -= 1
i = 0
while i <= N-1:
    if S[i]!=S[N-1-i]:
        flg = False
    i += 1
if flg:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
n=int(input())
march=["M","A","R","C","H"]
count=[0]*5
for i in range(n):
    s=input()
    for j in range(5):
        if s[0]==march[j]:
            count[j]+=1
c0=count[0]
c1=count[1]
c2=count[2]
c3=count[3]
c4=count[4]
ans=c0*c1*c2+c0*c1*c3+c0*c1*c4+c0*c2*c3+c0*c2*c4+c0*c3*c4+c1*c2*c3+c1*c2*c4+c1*c3*c4+c2*c3*c4
print(ans)

Measured memory_bytes: 3064
def main():
    
    n = int(input())
    
    Numbers = list(map(int,input().split()))
    count = 0
    for item in range(1,n+1):
        if item % 2 != 0 and Numbers[item-1] % 2 != 0:
            count += 1
    
    print(count)
        
    
  

if __name__ == "__main__":
    main()

Measured memory_bytes: 9104
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x)  upper_bound(all(v),x)
#define ff  first
#define ss  second
#define rev reverse
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x)    for(auto &a : x)
#define re(i,n)       for(ll i=0;i<n;++i) 
#define int2Bin(x,y)  bitset <y> z=x; cout<<z.to_string()<<endl;
const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
// int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
// int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int dx[4]={1, 0, 0, -1};
int dy[4]={0, -1, 1, 0};
ll power(ll x,ll y){ll ans=1;x=x;while(y>0){if(y&1)ans=(ans*x);y=y>>1;x=(x*x);}return ans;}
ll sqr(ll x) { return x * x;}
template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r){ll ans=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){ans*=(n-i);ans/=(i+1);}return ans;}
const int MOD=1000000007;   
const int N=100000;
struct compare{
    bool operator() (const int &a,const int &b) const{
        return a>b;
    }
};
void prec(){

}
void run(){ 
    int x;cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}   
int32_t main(){
    cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
        run();
    return 0; 
}
/* 
    stuff you should look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/


Measured memory_bytes: 3656
N=int(input())
x=[]
x=list(map(int,input().split()))
list.sort(x)
distance=(x[N-1]-x[0])//2
if N==1:print(0)
else:
    if distance==0:time=1
    elif (x[N-1]-x[0])%2==0:time=distance
    else:time=distance+1
    print(time)


Measured memory_bytes: 5612
#include<stdio.h>

int main(void){

 int a,b,c;
 scanf("%d %d %d", &a, &b, &c);

 int tmp;

 if(a > b){
  tmp = a;
  a = b;
  b = tmp; 
 }

 if(a > c){
  tmp = a;
  a = c;
  c = tmp;
 }
 
 if(b > c){
  tmp = b;
  b = c;
  c = tmp;
 }

 printf("%d %d %d\n", a, b, c);

 return 0;

}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
int a,b,c,i,j,n,s;
int main(int argc, char **argv){
    std::cin>>a>>b>>c>>n;
    for (i=0;i<=a;i++)
     for (j=0;j<=b;j++)
      if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)) ++s;
    printf("%d\n",s);
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    cout << (s <= "2019/04/30" ? "Heisei" : "TBD") << '\n';
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}

#pragma endregion



int main(void) {
	int N, L;
	int i = 0, tmp = 0, zero = 0;


	i_cin2(N, L);

	for (i = 0; i < N; i++) {
		tmp += (L + i);
	}
	if (!tmp) { i_cout(0); return 0; }
	if (L > 0) { i_cout(tmp - L); return 0; }

	if ((L < 0 && tmp>0) || !L) { i_cout(tmp); return 0; }
	i_cout(tmp+abs(L)-N+1);
	return 0;
}






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

int comp(const void *a,const void *b){
	long long int da = *(long long int*)a;
    long long int db = *(long long int*)b;
    if(da > db)
    	return 1;
    else if(da == db)
    	return 0;
    else return -1;
}

int main()
{
	long long a[100001][2];
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i = 0;i < n;i++)
		scanf("%lld %lld",&a[i][0],&a[i][1]);
		
	qsort(a,n,sizeof(a[0]),comp);
	long long sum = 0;
	int i = 0;
	while(m > a[i][1]){
		sum += a[i][1] * a[i][0];
		m -= a[i][1];
		i++; 
	}
	sum += m * a[i][0];
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include <string>
using namespace std;


int main(){
    int ans=0;
    int N;
    
    cin>>N;
    vector<pair<int,int>> xy(N);

    

    for(int i=0;i<N;i++){
        int a=0,b=0;
        cin>>a>>b;
        xy[i]=make_pair(a,b);
    }

    ans=50;

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            int p=xy[i].first-xy[j].first;
            int q=xy[i].second-xy[j].second;
            int count=0;

            for(int k=0;k<N;k++){
                for(int l=0;l<N;l++){
                    if(l==k){
                        continue;
                    }
                    if(xy[k].first-xy[l].first==p && xy[k].second-xy[l].second==q){
                        count++;
                    }
                }
            }
            ans=min(N-count,ans);
        }
    }

    cout<<ans<<endl;
    return 0;
}

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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int w,a,b;

main() {
    cin >> w >> a >> b;
    if (a>w+b) {
        ct(a-w-b)
    } else {
        ct(max((long long)0,b-w-a))
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() > k) {
    s = s.substr(0, k);
    s.push_back('.');
    s.push_back('.');
    s.push_back('.');
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;

char S[200010],T[200010];
int N,H,W;
int sr,sc;

int main() {
	scanf("%d%d%d",&H,&W,&N);
	scanf("%d%d",&sr,&sc);
	scanf("%s",S);
	scanf("%s",T);
	
	bool firstwin = false;
	int minx,maxx,miny,maxy;
	minx = maxx = sr;
	miny = maxy = sc;
	for (int i=0;i<N;i++) {
		if (S[i] == 'U') {
			minx--;
		}
		if (S[i] == 'D') {
			maxx++;
		}
		if (S[i] == 'L') {
			miny--;
		}
		if (S[i] == 'R') {
			maxy++;
		}
		if (minx <= 0 || maxx > H || miny <= 0 || maxy > W) {
			firstwin = true;
		}
		if (T[i] == 'U' && maxx > 1) {
			maxx--;
		}
		if (T[i] == 'D' && minx < H) {
			minx++;
		}
		if (T[i] == 'L' && maxy > 1) {
			maxy--;
		}
		if (T[i] == 'R' && miny < W) {
			miny++;
		}
		//printf("%d %d %d %d %d\n",i,minx,maxx,miny,maxy);
	} 
	puts(firstwin?"NO":"YES");
}

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

typedef long long lint;

const int MAXN = 100010;

int U[MAXN], V[MAXN], C[MAXN];
int uni[MAXN], sz[MAXN];

int guni(int x) { return x == uni[x] ? x : uni[x] = guni(uni[x]); }
void unite(int x, int y) { uni[guni(x)] = guni(y); }

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int N, Q;
	lint M;

	cin >> N >> M >> Q;
	for(int i = 0; i < Q; i++) cin >> U[i] >> V[i] >> C[i];

	for(int i = 0; i < N; i++) uni[i] = i;
	for(int i = 0; i < Q; i++) if(C[i] == 0) unite(U[i], V[i]);
	for(int i = 0; i < Q; i++) if(C[i] == 1 && guni(U[i]) == guni(V[i])) {
		cout << "No";
		return 0;
	}
	int cnt = 0;
	for(int i = 0; i < N; i++) if(i == uni[i]) cnt++;
	if(M > lint(cnt) * (cnt - 1) / 2 + N - cnt) {
		cout << "No";
		return 0;
	}
	for(int i = 0; i < Q; i++) if(C[i] == 1 && (M == N - 1 || cnt == 2)) {
		cout << "No";
		return 0;
	}
	if(cnt == 2 && M != N - 1) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;

static const int MAX = 4;

ll p[100001];
bool q[100001];
int main() {
	ll n; cin >> n;
	repe(i, 1, n) {
		cin >> p[i];
		//q[i] = (p[i] == i + 1);
	}
	ll cnt = 0;
	repe(i, 1, n) {
		if (i == p[i]) {
			swap(p[i], p[i + 1]);
			cnt++;
		}
		//if (q[i] || q[i + 1]) {
		//	swap(p[i], p[i + 1]);
		//	q[i] = false;
		//	q[i + 1] = false;
		//	cnt++;
		//}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <typeinfo>
#include <cmath>
using namespace std;
#define ll long long 
 
int countSetBits(ll val){
    int res = 0;
    while (val){
        res += val&1;
        val = val >> 1;
    }
    return res;
}
 
int main()
{
    ll MOD = 1e9 + 7;
    int N;
    cin >> N ;
    ll arr[N][N];
    for (int i=0; i<N; ++i) 
        for (int j=0; j<N; ++j) 
            cin >> arr[i][j];
    
    ll total_subsets = pow(2, N);            
    // dp[i] -> i in binary representation stores which women are already matched            
    ll dp[total_subsets] = {0};
    dp[0] = 1;
    
    for (ll i=1; i<total_subsets; ++i){
        // We can only match k men with k women, so counting the number of 1's in bitvector tells us for which man we are matching.
        int man = countSetBits(i);
        // We iterate over all matched women, and see if the jth women can actually get matched with @man
        for (int j=0; j<N; ++j){
            // If jth woman was already matched, we need to see if it couldve been matched with @man and add that count to dp[i]
            if (((i>>j)&1) && (arr[man-1][N-j-1]))
                dp[i] += dp[~(1<<j)&i];     
            dp[i] = dp[i] % MOD;
        }
    }
    
    cout << dp[total_subsets-1];
    return 0;
}

Measured memory_bytes: 16640
#include<stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2

int A[N][N],color[N],d[N],f[N];
int n,time = 0;

void dfs(int u){
  int v;
  color[u] = G;
  d[u] = ++time;
  for(v = 0; v < n; v++){
    if(A[u][v] == W) continue;
    if(color[v] == W) dfs(v);
  }
  color[u] = B;
  f[u] = ++time;
}

void dfs_init(){
  int i;
  for(i = 0; i < n; i++){
    color[i] = W;
  }
}


int main(){
  int i,j,a,b,c;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
     scanf("%d%d",&a,&b);
     a--;
     for(j = 0; j < b; j++){
       scanf("%d",&c);
       c--;
       A[a][c] = 1;
     }
   }
  dfs_init();
  dfs(0);
  for(i = 0; i < n; i++){
    if(color[i] == W) dfs(i);
    printf("%d %d %d\n",i + 1,d[i],f[i]);
  }
  
  return 0;
}



Measured memory_bytes: 2052
#include<stdio.h>
int main()
{
	char s[101];
	int n,x,i,ma;
	
	scanf("%d%s",&n,&s);
	
	for(i=0;i<n;i++){
		if(s[i]=='I')x++;
		else if(s[i]=='D')x--;
		if(x>ma)ma=x;
	}
	
	printf("%d\n",ma);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    string S;
    cin >> S;

    // output
    if (S[0] == S[1] && S[1] == S[2] ) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

var data [3][30]int
var d [][]int
var c [][]int

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	k := iScan()
	a := 7
	for i := 0; i < 10000000; i++ {
		if a%k == 0 {
			fmt.Println(i + 1)
			return
		}
		if a > k {
			a = a % k
		}
		a = a*10 + 7
	}
	fmt.Println(-1)
}

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    if (n * a > b) cout << b;
    else cout << n * a;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if((b-a)%2==0) cout<<(b-a)/2<<endl;
	else if(a==1 && b==n && n==2) cout<<1<<endl;
	else if(a==1 && b==n)  cout<<1+(n-2)/2<<endl;
	else if(a==1){
		if(b==2) cout<<1<<endl;
		else cout<<1+(b-2)/2<<endl;
	}
	else if(b==n){
		if(a==n-1) cout<<1<<endl;
		else cout<<1+(n-2)/2<<endl;
	}
	else if(b-1<=n-a){
		if(a+1==b) cout<<b-1<<endl;
		else cout<<a+(b-a-1)/2<<endl;
	}
	else{
		if(a+1==b) cout<<n-a<<endl;
		else cout<<n-b+1+(b-a-1)/2<<endl;
	}
}

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


int main(){
  int N;
  cin >> N;
  string s = "";
  
  while(N != 0) {
    int r = N % 2;
    if(r < 0) r += 2;
    N = (N - r) / (-2);

    s += (char)('0' + r);
  }
  reverse(s.begin(),s.end());
  if(s == "") s = "0";
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int i,j,k,n,m,w;
int main(){
	scanf("%d%d%d",&n,&m,&w);
	for (i=0,k=0;!k&&i<=n;i++)
	 for (j=0;!k&&j<=m;j++)
	  if (m*i+n*j-2*i*j==w) k=1;
	puts(k?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define MIN_INPUT_NUM	(3)
#define MAX_INPUT_NUM	(100)

static int search_number_of_pattern(int inputNum, int destinationNum);

int main(int argc, char *argv[])
{
	int inputNum;
	int destinationNum;
	int patternNum;

	while(1){

		/* ??\??? : inputNum = 0 and destinationNum = 0?????´????????????*/
		scanf("%d %d", &inputNum, &destinationNum);
		if(inputNum == 0 && destinationNum == 0){
			break;
		}

		/* ??????????????°????????? */
		patternNum = search_number_of_pattern(inputNum, destinationNum);

		/* ??????????????°?????¨??? */
		printf("%d\n", patternNum);

	}

	return 0;
}

static int search_number_of_pattern(int inputNum, int destinationNum)
{
	int i;
	int ii;
	int iii;
	int countPattern;

	countPattern = 0;
	for(i = 1; i <= inputNum; i++){
		for(ii = i + 1; ii <= inputNum; ii++){
			for(iii = ii+ 1; iii <= inputNum; iii++){
				if(destinationNum == i + ii + iii){
					countPattern++;
				}
			}
		}
	}

	return countPattern;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
	long N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<int> data(N, 0);
	int count = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (S.at(i) == 'A') {
			if (S.at(i + 1) == 'C')
				count++;
		}
		data.at(i+1) = count;
	}


	int ans, l, r;
	for (int i = 0; i < Q; ++i) {
		ans = 0;
		cin >> l >> r;
		ans = data.at(r-1);
		if (l-2 >= 0)
			ans -= data.at(l-1);
		cout << ans << endl;
	}
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

bool isleap(int year) {
    return year%4==0 && (year%100!=0 || year%400==0);
}

void solve93(int a, int b) {
    int cnt = 0;
    FOR(i,a,b+1) {
        if (isleap(i)) cout << i << endl, cnt++;
    }
    if (cnt == 0) cout << "NA" << endl;
}

int main() {
    int a, b;
    bool start = true;
    while(cin >> a >> b, a+b) {
        if (!start) cout << endl;
        solve93(a, b);
        start = false;
    }
    return 0;
}

Measured memory_bytes: 1160