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

#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vll vector<ll>
#define vvll vector<vll>
template<typename T, typename U> 
static inline void amin(T &x, U y){
	if(x>y)
		x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
	if(x<y)
		x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

int inf = 2e9+15;
ll INF = 2e18L+15;
const ll mod = 1e9+7;

int main(){
	int n;
	cin >> n;
	ll x;
	vll pref(64,0);
	vll one(64,0);
	rep(i,n){
		cin >> x;
		rep(j,62){
			if(x&(1ll<<j)){
				one[j] += ((ll)i-pref[j]);
			}else{
				one[j] += pref[j];
			}
			one[j] %= mod;
		}
		rep(j,62){
			if(x&(1ll<<j)){
				pref[j]++;
			}
		}
	}
	/*/rep(i,62){
		cout << one[i] <<" ";
	}*/
	//cout << endl;
	ll pow = 1;
	ll ans = 0;
	rep(i,62){
		ans += one[i]*pow;
		ans %= mod;
		pow *= 2;
		pow %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (A <= C && C <= B) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
std::vector<int> sieve(int n) {
  std::vector<int> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (int i = 2; i*i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}

std::vector<int> factor(int n, const std::vector<int>& min_factor) {
  // min_factor は sieve() で得られたものとする
  std::vector<int> res;
  while (n > 1) {
    res.push_back(min_factor[n]);
    n /= min_factor[n];
    // 割った後の値についても素因数を知っているので順次求まる
  }
  return res;
}
void solve()
{
	int n;
	cin>>n;
	ll ans=0;
	vector<int>s=sieve(1000001);
	FOR(i,1,n){
		vector<int>m=factor(i,s);
		map<int,int>cnt;
		set<int>num;
		rep(j,size(m)){
			num.insert(m[j]);
			cnt[m[j]]++;
		}
		ll cntt=1;
		for(auto j=num.begin(); j!=num.end();j++){
			cntt*=(cnt[*j]+1);

		}
		ans+=cntt;
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 7088
#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());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string s;
  cin >> s;

  if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes";
  else cout << "No";


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
  int n,k;
  cin >> n >> k;
  vector<bool> vc(n);
  for(int i=0;i<n;i++) vc[i] = false;
  for(int i=0;i<k;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int temp;
      cin >> temp;
      vc[temp-1] = true;
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    if(vc[i]==false) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    string x;
    cin >> x;
    long long temp = 0;
    long long ans = 0;
    for(long long i=0;i<x.length();i++){
        if(x[i]=='T'&&temp>0){
            temp--;
            ans++;
        }else if(x[i]=='S'){
            temp++;
        }
    }
    cout << x.length()-ans*2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  
using namespace std;  
// Important header files   
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;  
  
// Declaring ordered_set 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set; 
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s2 second
const ll INF=(1LL<<60)-1;


li gcd(li a,li b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
li lcm(li a,li b)
{
    return (a*b)/gcd(a,b);
}
li power(li a,li b)
{
    li res=1;
    while(b)
    {
        if(b&1)
        res=(res*a);
        a=((a)*(a));
        b>>=1;
    }
    return res;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const pair<li,li> &i, pair<li,li> &j)
{
    if(i.f==j.f)
    return i.s2 > j.s2;
    else
    return i.f<j.f;
    
}
bool ok(li a[],li mid,li k,li n)
{
    li moves=0;
    for(li i=0;i<n;i++)
    {
        moves+=(a[i]-1)/mid;
    }
    if(moves<=k)
    return true;
    return false;
}
void solve()
{
  li n,k;
  cin>>n>>k;
  li a[n];
  rep(i,n)
  cin>>a[i];
  li low=1,high=1000000001;
  li ans=1000000001;
  while(low<=high)
  {
      li mid=(low+high)/2;
      if(ok(a,mid,k,n))
      high=mid-1,ans=min(ans,mid);
      else
      low=mid+1;
  }
  cout<<ans;
}
signed main()
{
   //seive();
   //cout<<prime.size();
   FAST_IO;
   int t;
   t=1;
   while(t--)
   {
       solve();
       
   }
}

Measured memory_bytes: 5128
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

benefit = [V[i] - C[i] for i in range(N)]
benefit.sort(reverse=True)

ans = 0
for i in benefit:
    if (i > 0):
        ans += i

print(ans)

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

typedef long long int ll;

int main() {
    ll n; cin >> n;
    vector<ll> t(n+1, 0);

    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j+= i) {
            t[j]+=1;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (i * t[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81028
n = int(input())

if n == 1:
  print(0)
else:
  divl = [n]
  i = 2
  while i * i <= n:
    if n % i == 0:
      divl.append(i)
      divl.append(n // i)
    i += 1

  ans = 0
  for d in divl:
    if n == d * (n // (d - 1)):
      ans += d - 1
  print(ans)


Measured memory_bytes: 3280
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b, c, e;
	cin >> a >> b >> c;
	if (c > a + b + 1) {
		cout << a + b + 1 + b << endl;
	}
	else {
		cout << b + c << endl;
	}
	cin >> e;
}

Measured memory_bytes: 256
/*This Code Is Dirty And Not Proper For Under 18*/
/*Be Ma Nemikhori Vali Baramon Shayad*/
#include <bits/stdc++.h>
     
#define pb push_back
#define int long long
#define kill(x) return cout << x << endl , 0;
 
using namespace std;
     
const int inf = 1e18 + 10; 
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;

int dp[maxn][3] , a[maxn], b[maxn] , c[maxn];

int32_t main(){
    ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	int a[maxn];
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

	for(int i = 1 ; i < n ; i++){
		dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][2] , dp[i-1][0]) + b[i];
		dp[i][2] = max(dp[i-1][0] , dp[i-1][1]) + c[i];
	}
	cout << max(dp[n-1][0] ,max(dp[n-1][1] , dp[n-1][2])) << endl;
	return 0;
}

Measured memory_bytes: 8328
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define fname ""
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000
#define INF 1000000000000000000ll
const int N = 500;
int n;
ll a[N], k;

void inc() {
	int id = 1;
	for (int i = 2; i <= n; ++ i) {
		if (a[id] > a[i]) id = i;
	}

	a[id] += n;
	for (int i = 1; i <= n; ++ i) {
		if (id != i) a[i]--;
	}
}

int main() {
	
	cin >> k;
	
	n = 50;
	ll mn = k / n;
	
	for (int i = 1; i <= n; ++ i) {
		a[i] = mn + i - 1;
	}

	k %= n;

	for (int i = 1; i <= k; ++ i) inc();

	cout << n << endl;
	for (int i = 1; i <= n; ++ i) cout << a[i] << " ";
        
    return 0;
}


Measured memory_bytes: 256
from sys import stdin


r, D, x_2000 = [int(x) for x in stdin.readline().rstrip().split()]

x = []
x.append(r * x_2000 - D)
for i in range(1,10):
    x.append(r * x[i-1] - D)

for i in range(0,10):
    print(x[i])

Measured memory_bytes: 3060
a, b = map(int,input().split())
if a == 1:
    if a < b:
        print('Alice')
    else:
        print('Draw')
elif b == 1:
    if a > b:
        print('Bob')
    else:
        print('Draw')
else:
    if a < b:
        print('Bob')
    elif a > b:
        print('Alice')
    else:
        print('Draw')

Measured memory_bytes: 61616
N,x = map(int,input().split())
A = list(map(int,input().split()))

if sum(A) < x:
    print(N-1)
else:
    A.sort()
    count = 0
    while(x > 0):
        x -= A[count]
        if x >= 0:
            count += 1
    print(count)
    
# 子供が喜ぶお菓子の合計sum(A)が配れるお菓子の数xより大きいか否かで場合分け
# sum(A) < x　のとき子供全員にお菓子は配れるが、余りが発生するので一人は喜ばない

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;

struct eT
{
	void setd ( int _u, int _v, int _l )
	{
		u = _u, v = _v, last = _l;
	}
	
	int u, v, last;
}edge[MAXN];

int n;
int ke, la[MAXN];
int p[MAXN];
bool ins[MAXN];
int stk[MAXN], top;
int cyc[MAXN], kc;
bool inc[MAXN];
int dp[MAXN];
bool hv[MAXN];

void init ();
void input ();
void work ();

int getval ( int now )
{
	for ( int i = la[now]; ~i; i = edge[i].last ) hv[dp[edge[i].v]] = true;
	int ans = -1;
	lp ( i, 0, MAXN ){
		if ( !hv[i] ){
			ans = i;
			break;
		}
	}
	for ( int i = la[now]; ~i; i = edge[i].last ) hv[dp[edge[i].v]] = false;
	return ans;
}

void dfs ( int now )
{
	for ( int i = la[now]; ~i; i = edge[i].last ) if ( !inc[edge[i].v] ) dfs ( edge[i].v );
	dp[now] = getval ( now );
}



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
	lpi ( i, 1, n ) scanf ( "%d", &p[i] );
}

void work ()
{
	// main work
	
	INIT ( la, -1 );
	lpi ( i, 1, n ){
		edge[ke].setd ( p[i], i, la[p[i]] );
		la[p[i]] = ke++;
	}
	
	int now = 1;
	while ( 1 ){
		if ( ins[now] ){
			while ( stk[top] ^ now ) cyc[++kc] = stk[--top];
			break;
		}
		ins[now] = true;
		stk[top++] = now;
		now = p[now];
	}
	
	reverse ( cyc+1, cyc+1+kc );
//	lpi ( i, 1, kc ) cerr << cyc[i] << " "; cerr << endl;
	lpi ( i, 1, kc ) inc[cyc[i]] = true;
	lpi ( i, 1, kc ) dfs ( cyc[i] );
	
	dp[cyc[kc]] = MAXN-1;
	dp[cyc[1]] = getval ( cyc[1] );
	lpi ( i, 2, kc ) dp[cyc[i]] = getval ( cyc[i] );
	if ( dp[cyc[1]] == getval ( cyc[1] ) ){
		cout << "POSSIBLE" << endl;
		return;
	}
	dp[cyc[kc]] = dp[cyc[1]];
	dp[cyc[1]] = getval ( cyc[1] );
	lpi ( i, 2, kc ) dp[cyc[i]] = getval ( cyc[i] );
	cout << ( ( dp[cyc[1]] == getval ( cyc[1] ) ) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define double long double
#define int long long 
#define f(z) for(int i=1;i<=z;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
int cl(int n ,int m) { if(n%m)return n/m + 1 ;else return n/m ;}
int pw(int a,int b,int M){a%=M;int r=1;while(b>0){if(b&1)r=r*a%M;a=a*a%M;b>>=1;}return r;}
#define mod  1000000007
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e6 + 5  ;

signed main(){
	int n; 
	cin >>n; 
	double t = (double)n/(double)3 ;
	t = t * t * t ;
	cout << fixed <<setprecision(6) << t << endl ;
	//printf("%.6f"  , t) ;
}

Measured memory_bytes: 256
from collections import Counter

def combination(n, r): #nCrを求める
    if n - r > r:
        r = n - r
    tmp = 1
    for i in range(n - r + 1, n + 1):
        tmp *= i
    for i in range(1, r + 1):
        tmp //= i
    return tmp

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

B = [A[i] % 2 for i in range(N)]

C = Counter(B)

odd = C[1]
even = C[0]

ans = 0
for i in range(P, odd + 1, 2):
    tmp = combination(odd, i)
    ans += tmp

ans *= pow(2, even)
print (ans)



Measured memory_bytes: 3316
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o D.exe D.cpp 
Execute: ./D
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n;
	char arr[200000]; 
	char stone; 
	
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> stone; 
		if(stone == 'R')
			arr[i] = 0; 
		else 
			arr[i] = 1; 
	}
	
	int noOfZeroes[200000]; 
	int noOfOnes[200000]; 
	memset(noOfZeroes, 0, sizeof(noOfZeroes)); 
	memset(noOfOnes, 0, sizeof(noOfOnes)); 
	
	int i, count = 0; 
	
    // Count number of zeroes 
    // on right side of every one. 
    noOfZeroes[n - 1] = 1 - arr[n - 1]; 
    for (i = n - 2; i >= 0; i--) { 
        noOfZeroes[i] = noOfZeroes[i + 1]; 
        if (arr[i] == 0) 
            noOfZeroes[i]++; 
    } 
	
	
	// Count number of ones on left side of every one. 
	for(int i = 1; i < n; i++) {
		noOfOnes[i] = noOfOnes[i-1]; 
		if(arr[i-1] == 1) 
			noOfOnes[i]++;
	}
  
	// Count from right
	for(int i = n-1; i >= 0; i--) {
		if(arr[i] == 1) {
			if(max(0, noOfZeroes[i] - noOfOnes[i]) - count > 0) 
				count++; 
		}
	}
	
		
	cout << count << endl; 
	
	return 0; 
} 


Measured memory_bytes: 5364
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    cin >> n;
    if(n==2){
        cout << -1 << endl;
        return 0;
    }
    vector<int>a(n+1);
    vector<int>c(n+1);
    vector<int>pre(n+1);
    rep(i,n){
        cin >> a[i+1];
        c[a[i+1]]++;
        pre[a[i+1]] = c[a[i+1]];
    }
    set<pair<int,int>,greater<pair<int,int> > > s;
    set<int> st;
    rep(i,n){
        s.insert(MP(c[i+1],i+1));
        st.insert(i+1);
    }
    vector<int> res;
    for(int i=0;i<n-3;i++){
        auto x = *s.begin();
        int k = x.first;
        int z = x.second;
        if(k==n-i-1){
            res.push_back(z);
            s.erase(x);
            st.erase(z);
            int y = a[z];
            if(st.count(y)){
                s.erase(MP(pre[y],y));
                pre[y]--; 
                s.insert(MP(pre[y],y));
            }
        }else{
            int p = 0;
            if(i!=0)p = a[res[i-1]];
            auto z = st.begin();
            int nx;
            if(p!=(*z)){
                nx = *z;
            }else{
                z++;
                nx = *z;
            }
            res.push_back(nx);
            st.erase(nx);
            s.erase(MP(pre[nx],nx));
            int y = a[nx];
            if(st.count(y)){
                s.erase(MP(pre[y],y));
                pre[y]--; 
                s.insert(MP(pre[y],y));
            }
        }
    }
    // for(auto x:res){
    //     cerr << x << " ";
    // }
    // cerr << endl;
    vector<int> v;
    for(auto x:st){
        v.push_back(x);
    }
    int ng;
    if(n>3) ng = a[res[n-4]];
    else ng = 0;
    do{
        if(v[0]==ng)continue;
        if(v[1]==a[v[0]])continue;
        if(v[2]==a[v[1]])continue;
        res.push_back(v[0]);
        res.push_back(v[1]);
        res.push_back(v[2]);
        break;
    }while(next_permutation(v.begin(),v.end()));
    rep(i,n-1){
        if(a[res[i]]==res[i+1])assert(0);
    }
    for(auto x:res){
    
        cout << x << " ";
    }
    cout << endl;
    return 0;   
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

using namespace __gnu_pbds;
using namespace std ;

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

#define maxn 1000005

int fact[maxn] ;
string s ;

int C(int n, int r)
{
    if(r<0 || n<0 || n<r) return 0 ;
    if( (fact[n]-fact[r]-fact[n-r]) == 0 ) return 1 ;
    return 0 ;
}

int f(string s)
{
    int n = (int)s.size() ;

    int res = 0 ;

    for(int i=0 ; i<n ; i++)
    {
        res += ( s[i]-'0' )*C(n-1,i) ;
    }
    res %= 2;
    return res ;
}

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

    for(int i=1 ; i<maxn ; i++)
    {
        int j = i , c = 0 ;
        while( j%2 == 0 )
        {
            j /= 2 ;
            c++ ;
        }
        fact[i] = fact[i-1] + c ;
    }

    int n ;
    cin>>n ;

    string t,s ;
    cin>>t ;

    for(int i=1 ; i<n ; i++)
    {
        char ch ;
        ch = abs( t[i]-t[i-1] ) + '0' ;
        s += ch ;
    }

    n-- ;

    int one = 0 ;

    for(int i=0 ; i<n ; i++)
    {
        if( s[i]=='1' ) one++ ;
    }

    if(one==0)
    {
        for(int i=0 ; i<n ; i++)
        {
            if(s[i]=='2') s[i] = '1' ;
        }
        int res = f(s) ;
        if(res==0) printf("0\n") ;
        else printf("2\n") ;
        return 0 ;
    }

    for(int i=0 ; i<n; i++)
    {
        if(s[i]=='2') s[i] = '0' ;
    }

    int res = f(s) ;

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

    return 0 ;
}


Measured memory_bytes: 7196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] v1 = new int[100001];
		int[] v2 = new int[100001];
		int[] v11 = new int[2];
		int[] v12 = new int[2];
		int[] v21 = new int[2];
		int[] v22 = new int[2];
		
		for(int i = 0; i < n; i++) {
			if(i % 2 == 0 || i == 0) {
				int a = sc.nextInt();
				v1[a]++;

			} else {
				int b = sc.nextInt();
				v2[b]++;
			}
		}
		
		v11 = saidai(v1);
		v1[v11[0]] = 0;
		v12 = saidai(v1);
		
		v21 = saidai(v2);
		v2[v21[0]] = 0;
		v22 = saidai(v2);
		
		if(v11[0] == v21[0]) {
			if(v11[1] + v22[1] >= v12[1] + v21[1]) {
				System.out.println(n - v11[1] - v22[1]);
			} else {
				System.out.println(n - v12[1] - v21[1]);
			} 
		} else {
			System.out.println(n - v11[1] - v21[1]);
		}
	}
	
	public static int[] saidai(int[] x) {
		int m = 0;
		int[] ret = new int[2];
		for(int i = 0; i < x.length; i++) {
			if(m < x[i]) {
				m = x[i];
				ret[0] = i;
				ret[1] = x[i];
			}
		}
		return ret;
	}
}


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

ll n, w, weight, value, bd[100][100001];

int main() {
	cin >> n >> w;
    cin >> weight >> value;
    for (int i=0; i<=w; i++) {
    	if (i<weight) 
            bd[0][i] = 0;
        else bd[0][i] = value;
    }
    
    for (int i=1; i<n; i++) {
    	cin >> weight >> value;
        for (int j=0; j<=w; j++) {
        	bd[i][j] = max(bd[i-1][j], bd[i][j-1]);
            if (j>=weight) {
                bd[i][j] = max(bd[i][j], bd[i-1][j-weight]+value);
            }
        }
    }
    cout << bd[n-1][w] << "\n";
    return 0;
}

Measured memory_bytes: 78336
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1
mx = 0
for i in d.values():
  mx = max(mx, i)
for i in sorted(d.items()):
  if i[1] == mx:
    print(i[0])

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

int main(void)
{
	int k,i,t;
	char s[101];

	scanf("%d",&k);
	scanf("%s",s);

       t=strlen(s);
         
          if(t<=k)
		printf("%s",s);
	 else 
	       printf("%.*s...",k,s);
	 return 0;
	
}




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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
   	int a,b;
   	cin>>a>>b;
   	if(a%b==0)cout<<(a/b);
   	else cout<<(a/b+1);

}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int r,d, x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        x = x*r - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec a(n),b(n);
  ll sa=0,sb=0;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    sa+=a[i];
  }
  for(ll i=0;i<n;i++) {
    cin >> b[i];
    sb+=b[i];
  }
  if(sa>sb) {
    cout << "No" << endl;
    return 0;
  }
  ll cnt=0;
  for(ll i=0;i<n;i++) {
    if(a[i]>=b[i]) {
      cnt+=a[i]-b[i];
    }
    else {
      cnt+=(a[i]%2!=b[i]%2);
    }
  }
  if(cnt>sb-sa) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

char getBond(char c){
  if(c == 'A') return 'T';
  if(c == 'T') return 'A';
  if(c == 'G') return 'C';
  if(c == 'C') return 'G';
}

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

    char x ;
    cin >> x;
    cout << getBond(x) << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
import java.util.*;


public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s=new Scanner(System.in);
		int N=s.nextInt();
		int M=s.nextInt();
	    String A[]=new String[N];
		String B[]=new String[M];
		int i=0,j=0,k=0,l=0;
		boolean f=true;
		
		for(i=0;i<N;i++){
			A[i]=s.next();
		}
		for(i=0;i<M;i++){
			B[i]=s.next();
		}
		
		for(i=0;i<N-M+1;i++){
			for(j=0;j<N-M+1;j++){
				for(k=0;k<M;k++){
					for(l=0;l<M;l++){
						if(A[i+k].charAt(j+l)!=B[k].charAt(l)){
							f=false;
							break;
						}
					}
				}
				if(f==true){
					System.out.println("Yes");
					System.exit(0);
				}
				f=true;
			}
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 22608
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>

#define ll long long

using namespace std;

/*   Every goose should go to prison!!!!!
     ██▀▀▄  ██     ██
▄███▀██░░░▌ ██     ██
█████████████████████████████
    ▐██░░░▐ ██     ██
    ▌██░░░░▐██     ██
█████████████████████████████
   ▐░██░▐▒▒▒██▒▒▒▀▀██
   ▐░██░▐▄▒▒██▒▒▒▒▒██▄
█████████████████████████████
     ██▄▄▄▄▄██▄▄▄▄▄██▄▄▄▀▄
     ██    ▌██▌▌   ██
█████████████████████████████
     ██  ▄▄▌██▌▌   ██ */

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a;

    return 0;
}


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

using namespace std;

int bubbleSort(int A[], int N) 
{
  int changecount = 0;
  bool flag = 1;
  for (int i = 0; flag; i++){
    flag = 0;
    for (int j =  N - 1;  j >= i + 1; j--){
      if (A[j] < A[j - 1]){
        swap(A[j], A[j - 1]);
        flag = 1;
        changecount++;
      }
    }
  }
  
  return changecount;
}

int main()
{
  int n;
  int changecount;
  cin >> n;
  int A[n];
  for (int i = 0; i < n; i++) cin >> A[i];
  changecount = bubbleSort(A, n);
  for (int i = 0; i < n; i++){
    if (i != 0){
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  cout << changecount << endl;
  return 0;
}



Measured memory_bytes: 3104
def func():
    N = int(input())
    H = list(map(int, input().split()))

    count = N

    for i in range(1, N):
        for k in range(i):
            if (H[k] > H[i]):
                count -= 1
                break

    print(count)


if __name__ == '__main__':
    func()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define N 3005
int n,ans,mod,f[N],g[N][N],C[N][N];
int mul(int x,int y){
	return 1ll*x*y%mod;
}
int Pow(int x,int y,int p){
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%p)
		if(y&1)res=1ll*res*x%p;
	return res;
}	
int main(){
    scanf("%d%d",&n,&mod);
    for(int i=0;i<=n;i++){
        C[i][0]=g[i][0]=1;
        for(int j=1;j<=i;j++){
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
            g[i][j]=(g[i-1][j-1]+mul(j+1,g[i-1][j]))%mod;
		}
    }
    for(int i=0;i<=n;i++){
        int tmp=Pow(2,Pow(2,n-i,mod-1),mod);
        int num=Pow(2,n-i,mod),qaq=1,res=0;
        for(int j=0;j<=i;j++){
			res=(res+mul(g[i][j],qaq))%mod;
			qaq=mul(qaq,num);
		}
        ans=(ans+mul(mul((i&1)?mod-C[n][i]:C[n][i],tmp),res))%mod;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 58860
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	set<int> diameters;
	int d;
	for (int i = 0; i < n; ++i) {
		cin >> d;
		diameters.insert(d);
	}

	cout << diameters.size() << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define INF 1<<20
int main() {
	int n, k;
	cin >> n >> k;
	
	long long a[n+1]={};
	a[0]=1;
	for (int i=1; i<=n; i++) {
		a[i]=(a[i-1]*k)%1000000007;
	}
	cout << a[n] << endl;
}


Measured memory_bytes: 3128
from collections import defaultdict

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
        return

    if self.parents[x] > self.parents[y]:
        x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, q = map(int, input().split())
TUV = [list(map(int, input().split())) for _ in range(q)]
  
uf = UnionFind(n)
for t, u, v in TUV:
  if t == 0:
    uf.union(u, v)
  else:
    print(1 if uf.same(u, v) else 0)

Measured memory_bytes: 45872
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N,K,i;
    cin >> N >> K;

    long long int ans = K;
    
    for(i = 0; i < N -1; i++) {
        ans *= (K - 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int main(){
	int d[15][15];
	int n,cnt,f;
	int x,y;
	for(;;){
		scanf("%d",&n);
		if(!n)break;
		rep(i,n)rep(j,n)d[i][j]=0;
		cnt=0;
		x=n/2;
		y=n/2+1;
		while(cnt<n*n){
			f=0;
			while(d[x][y]>0){
				y=y==n-1?0:y+1;
				if(f){
					x=x==0?n-1:x-1;
					continue;
				}
				f=1;
				x=x==n-1?0:x+1;
			}
			d[x][y]=++cnt;
		}
		rep(i,n){rep(j,n)printf("%4d",d[j][i]);puts("");}
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
int main()
{
	dhoom;
	int n , k;
	int x;
	cin >> n >> k;
	for(int i = 0 ; i < n ; i++)
		cin >> x;
	cout << (n - 1 + k - 2)/(k-1) << endl;
	return 0;
} 



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

using namespace std;

int main()
{
    map<string,int>m;
    string s;
    int i,t,j,n,z;
    cin>>t;
    for (i=1;i<=t;++i){

        cin>>n;
        if (n==0){

            cin>>s>>z;
            m[s]=z;


        }
        else{

            cin>>s;
            cout<<m[s]<<'\n';

        }

    }

    return 0;
}



Measured memory_bytes: 27816
#include<stdio.h>
int main(){
	int cards[4][14] = {};
	char mark;
	int num,n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%c %c %d",&mark,&mark,&num);
		//printf("%c %d\n",mark,num);
		int q = 0;
		if(mark == 'S')q=0;
		else if(mark == 'H')q=1;
		else if(mark == 'C')q=2;
		else if(mark == 'D')q=3;
		cards[q][num] = 1;
	}
	for(int i=0;i<4;i++){
		if(i == 0)mark='S';
		else if(i == 1)mark='H';
		else if(i == 2)mark='C';
		else if(i == 3)mark='D';
		for(int j=1;j<14;j++){
			if(cards[i][j]==0)printf("%c %d\n",mark,j);
		}
	}
	return 0;
}


Measured memory_bytes: 2052
#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;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

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

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int n;
	cin>>n;
	int t[n+1],x[n+1],y[n+1];
	t[0]=x[0]=y[0]=0;
	for(int i=1;i<n+1;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	bool flag=true;
	REP(i,n){
		int dt=t[i+1]-t[i];
		int dx=x[i+1]-x[i];
		int dy=y[i+1]-y[i];
		if((dt>=(dx+dy) && (dt-dx-dy)%2==0)){
			continue;
		}else{
			flag=false;
			break;
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  ll N, M;
  cin >> N >> M;
  
  if(M%2 == 0){
    for(ll i=0;i<M/2;i++){
      cout << i+1 << " " << M+1-i << endl;
    }
    for(ll i=0;i<M/2;i++){
      cout << M+i+2 << " " << 2*M+1-i << endl;
    }
  }else{
    for(ll i=0;i<(M+1)/2-1;i++){
      cout << i+1 << " " << M-i << endl;
    }
    for(ll i=0;i<(M+1)/2;i++){
      cout << M+i+1 << " " << 2*M+1-i << endl;
    }
  }
}

Measured memory_bytes: 3640
N, M = map(int, input().split())

num_in = [0] * (N+1)
graph = [[] for i in range(N+1)]
for i in range(N+M-1):
  a, b = map(int, input().split())
  num_in[b] += 1
  graph[a].append(b)

for i in range(1, N+1):
  if num_in[i] == 0:
    root = i
    break

par = [-1] * (N+1)
par[root] = 0
d = [root]
while d:
  node = d.pop()
  children = graph[node]
  for child in children:
    num_in[child] -= 1
    if num_in[child] == 0:
      par[child] = node
      d.append(child)

print(*par[1:], sep='\n')

Measured memory_bytes: 21920
n,q = map(int, input().split())
s = input()


num_ac = [0] * n
num_ac[0] = 0
if s[0] == "A" and s[1] == "C":
    num_ac[1] = 1


for i in range(2,n):
    if s[i-1] == "A" and s[i] == "C":
        num_ac[i] = num_ac[i-1] + 1
    else:
        num_ac[i] = num_ac[i-1]

ans = [0] * q
for i in range(q):
    l,r = map(int, input().split())
    ans[i] = num_ac[r-1] - num_ac[l-1]

for a in ans:
    print(a)



Measured memory_bytes: 10300
H,W=map(int,input().split())
lst=[[0]*W for _ in range(H)]
for i in range(H):
  lst[i]=list(map(int,input().split()))
N=0
tmp=[]
for i in range(H):
  for j in range(W):
    if lst[i][j]%2==0:
      pass
    else:
      if 0<=j<=W-2:
        lst[i][j+1]+=1
        N+=1
        tmp.append([str(i+1),str(j+1),str(i+1),str(j+2)])
      if j==W-1:
        if i+1<=H-1:
          lst[i+1][j]+=1
          N+=1
          tmp.append([str(i+1),str(j+1),str(i+2),str(j+1)])

print(N)
for i in range(len(tmp)):
  print(' '.join(tmp[i]))

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

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int MAX = 110;
int operand[110];
int top;

int main(){
  char x2;
  char *x1;
  int p1,p2;
  int s;
  initialize();
  x1 = &x2;
  while(1){
    if(scanf(" %s",x1)==EOF)break;

    if(x2 == '*'){
      p1 = pop();
      p2 = pop();
      push(p1*p2);
    }
    else if(x2 == '+'){
      p1 = pop();
      p2 = pop();
      push(p1+p2);
    }
    else if(x2 == '-'){
      p1 = pop();
      p2 = pop();
      push(p2-p1);
      }    
    else{
      push(atoi(x1));
    }
  }
  printf("%d\n",operand[top]);
  return 0;
}

void initialize(void){
  top = 0;
}

int isEmpty(void){
  return top == 0;
}

int isFull(void){
  return top >= MAX - 1;
}

void push(int kazu){
  if(isFull()){
    printf("Error1\n");
    exit(0);
  }
  top++;
  operand[top] = kazu;
}

int pop(void){
  if(isEmpty()){
    printf("Error2\n");
    exit(1);
  }
  top--;
  return operand[top+1];
}

Measured memory_bytes: 548
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
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; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));


int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++) cin >> A[i][j];
    }
    vector<int> B(M);
    for(int i = 0; i < M; i++) cin >> B[i];

    vector<int> ans(N);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++) ans[i] += A[i][j] * B[j];
    }
    for(int a : ans) cout << a << endl;
}


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

using namespace std;

int main(void){
    int A,B;
    cin >> A >> B;
    if((A+B) >= 10){
        cout << "error" << endl;
        return 0;
    }
    else{
        cout << A+B << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		String[] s = new String[n];
		int cnt1 = 0;
		int cnt2 = 0;
		int cnt3 = 0;
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
			if(s[i].substring(0, 1).equals("B") &&s[i].substring(s[i].length()-1, s[i].length()).equals("A")) {
				cnt1 ++;
			}else if(s[i].substring(0, 1).equals("B")) {
				cnt2 ++;
			}else if(s[i].substring(s[i].length()-1, s[i].length()).equals("A")) {
				cnt3 ++;
			}
		}
		if(cnt1 == 0) {
			ans += cnt1 + Math.min(cnt2, cnt3);
		}else if(cnt2 + cnt3!= 0) {
			ans += cnt1 + Math.min(cnt2, cnt3);
		}else {
			ans += cnt1-1;
		}
		String[] t = new String[n];
		for(int i = 0; i < n; i++) {
			t[i] = s[i];
			t[i] = t[i].replace("AB", "X");
			ans += s[i].length() - t[i].length();
		}
		System.out.println(ans);
		sc.close();
	}
}


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

int main(){  
	string cards[3];
	cin >> cards[0] >> cards[1] >> cards[2];
	int now = 0;
	while(cards[now] != ""){
		char FrontText = cards[now].front();
		cards[now].erase(cards[now].begin());
		if(FrontText == 'a'){
			now = 0;
		}else if(FrontText == 'b'){
			now = 1;
		}else if(FrontText == 'c'){
			now = 2;
		}
	}
	if(now == 0){
		cout << "A" << endl;
	}else if(now == 1){
		cout << "B" << endl;
	}else if(now == 2){
		cout << "C" << endl;
	}
}

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

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

    std::set<std::string> s;
    std::string str;
    for (int i = 0; i < N; ++i) {
        std::cin >> str;
        s.insert(str);
    }

    std::cout << s.size() << std::endl;

    return 0;
}


Measured memory_bytes: 19236
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=300010,M=100010;
int n,m,q,ans=0;
int v[N],w[N],d[N],f[1030][M];
inline void dfs1(int x)
{
    d[x]=d[x/2]+1;
    for(int k=0;k<=1e5;k++)
        f[x][k]=f[x/2][k];
    for(int k=w[x];k<=1e5;k++)
        f[x][k]=max(f[x][k],f[x/2][k-w[x]]+v[x]);
    if(d[x]==m) return;
    dfs1(x<<1);
    dfs1(x<<1|1);
    return;
}
inline void dfs2(int x,int y,int z)
{
    if(d[x]==m)
    {
        ans=max(ans,z+f[x][y]);
        return;
    }
    if(y>=w[x]) dfs2(x/2,y-w[x],z+v[x]);
    dfs2(x/2,y,z);
    return;
}
int main()
{
    scanf("%d",&n);
    m=log2(n)/2;
    if(m==0) m=1;
    for(int k=1;k<=n;k++)
        scanf("%d%d",&v[k],&w[k]);
    dfs1(1);
    scanf("%d",&q);
    while(q--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ans=0;
        if(d[x]) printf("%d\n",f[x][y]);
        else dfs2(x,y,0ll),printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 105512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    cin >> a;

    for(int i = 0; i+k < n; ++i){
        Judge(a[i] < a[i+k]);
    }
    
    
    return 0;
}


Measured memory_bytes: 4780
#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 x;
  cin >> x;
  int h = 0;
  h += x / 500 * 1000;
  x %= 500;
  h += x / 5 * 5;
  cout << h << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

static int32_t get_keta(int64_t num)
{
	int32_t res = 0;
	while (num > 0) {
		num /= 10;
		res++;
	}
	return res;
}

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

	int32_t res = 100;

	for (int64_t i = 1; i * i <= N; i++) {
		if (N % i != 0)
			continue;
		int64_t sho = N / i;
		res = min(res, max(get_keta(i), get_keta(sho)));
	}

	cout << res << endl;

	return 0;
}

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

int main(){
  int n,i;
  cin >> n;
  vector<int>a(n),b(n);

  for(i=0;i<n;++i){
    cin >> a[i] >> b[i];
  }
  vector<pair<int,int>>ab(n);
  for(i=0;i<n;++i){
    ab[i]=make_pair(b[i],-a[i]);
  }
  sort(ab.begin(),ab.end());
  int sum=0;
  for(i=0;i<n;++i){
    sum=sum-ab[i].second;
    if(sum>ab[i].first){
      cout << "No" << endl;
      return 0;
    }

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

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
double pi=acos(-1),a,b,n,m;
int main(){
	scanf("%lf%lf%lf%lf",&a,&b,&n,&m);
	double x=(n/12.0+m/60.0/12.0-m/60.0)*2.0*pi;
	printf("%.20lf\n",sqrt(a*a+b*b-2*a*b*cos(x)));
	return 0;
}

Measured memory_bytes: 4212