akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;

int main() {
    
    cin.sync_with_stdio(0); cin.tie(0); 
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        ll ans=0;
        ll len=0;
        int x=n;
        int af,al;
        al=x%10;
        while(x!=0){
            af=x%10;
            len++;x=x/10;
        }
        ll power[10];
        power[0]=1;
        repA(i,1,9)power[i]=power[i-1]*10;
        ll num=0;
        x=n;
        x=x/10;
        int j=0;
        while(x!=0){
            ll t=x%10;
            x=x/10;
            if(x!=0){
                num=num+t*power[j];j++;
            }
        
        }     
        num++;
        // cout<<af<<" "<<al<<endl;
        // cout<<num<<endl;
        for(ll i=1;i<=n;i++){
            ll f,l;
            ll t=i;
            f=i%10;
            while(t!=0){
                l=t%10;
                t=t/10;
            }
            if(f==0)continue;
            ll u=ans;
            // cout<<f<<" "<<l<<endl;
            for(int j=1;j<=len;j++){
                if(j==1){
                    if(l==f&&l<=n){
                        ans++;
                    }
                }
                else if(j==len){
                    if(af>f){
                        ans=ans+power[j-2];
                    }
                    else if(af==f){
                        ans=ans+num;
                        if(al<l){
                            ans--;
                        }
                    }
                }
                else{
                    ans=ans+power[j-2];
                }
            }
            // cout<<ans-u<<endl;
        }
        cout<<ans;
    }
    return 0;   
}

Measured memory_bytes: 256
while 1:
    a, b, c = map(int, raw_input().split())
    if a == b == c == 0:
        break
    xs = [2] * (a + b + c)
    ngs = []
    for i in range(int(raw_input())):
        vs = map(int, raw_input().split())
        ijk = vs[:3]
        if vs[3] == 1:
            for v in ijk:
                xs[v - 1] = 1
        else:
            ngs.append(ijk)
    for ijk in ngs:
        c = 0
        unk = -1
        for v in ijk:
            x = xs[v - 1]
            if x == 1:
                c += 1
            elif x == 2:
                unk = v
        if c == 2:
            xs[unk - 1] = 0
    print '\n'.join(map(str, xs))

Measured memory_bytes: 4296
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N = 3;
const int dx[4] = {0,1,0,-1},dy[4] = {1,0,-1,0};

int mat[N][N];
int lim;

int getMD(){
  int sum = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(mat[i][j] == N*N-1) continue;
      sum += abs(mat[i][j]/N-i) + abs(mat[i][j]%N-j);
    }
  }
  return sum;
}

bool IDAstar(int depth,int prev,int py,int px){
  int MD = getMD();
  if(MD == 0) return true;
  if(depth + MD > lim) return false;

  for(int k = 0; k < 4; k++){
    int ny = py + dy[k];
    int nx = px + dx[k];
    if(ny < 0 || N <= ny || nx < 0 || N <= nx) continue;
    if(abs(k - prev) == 2) continue;
    swap(mat[ny][nx],mat[py][px]);
    if(IDAstar(depth+1,k,ny,nx)) return true;
    swap(mat[ny][nx],mat[py][px]);
  }
  return false;
}

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

  int py,px;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cin >> mat[i][j];
      if(mat[i][j] == 0){
        mat[i][j] = N*N;
        py = i;
        px = j;
      }
      mat[i][j]--;
    }
  }

  for(lim = 0; lim < 100; lim++){
    if(IDAstar(0,100,py,px)){
      cout << lim << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+6;
int n,a[maxn];
vector<int> E[maxn];
void dfs(int x,int p){
    if(E[x].size() == 1)return;
    long long sum = 0;
    long long mx = 0;
    for(int i=0;i<E[x].size();i++){
        int v = E[x][i];
        if(v==p)continue;
        dfs(v, x);
        sum += a[v];
        mx = max(1ll*a[v], mx);
    }
    if(a[x]>sum||sum>2*a[x]){
        cout<<"NO"<<endl;
        exit(0);
    }
    int k=sum-a[x];
    if(k>sum-mx){
        cout<<"NO"<<endl;
        exit(0);
    }
    a[x]-=k;
}
int main()
{
    scanf("%d", &n);
    for(int i=0;i<n;i++)
        scanf("%d", &a[i]);
    for(int i=1;i<n;i++){
        int x,y;
        scanf("%d%d", &x, &y);
        x--,y--;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    if(n==2){
        if(a[0]==a[1])puts("YES");
        else puts("NO");
        return 0;
    }
    int v=0;
    while(E[v].size() == 1) v++;
    dfs(v, -1);
    if(a[v]==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 12800
#include <iostream>

using namespace std;

int main()
{
int a,b,c,d;
	cin>>a;
	cin>>b;
	cin>>c;
	d=0;
		if(a==b)
		{
			if(c%a==0)//?´???°?????£?????????(?´???°?????°)??????1
			{
				d++;}
	}
		else
		{
			while(a<=b){
				if(c%a==0){
					a++;
					d++;}
			else if(c%a>0){
				a++;}
			}
		}
	cout<<d<<endl;
			
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  bool chk = true;

  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    bool tmpchk = true;

    if(tmp % 2 == 0){
      if(tmp % 3 == 0 || tmp % 5 == 0){
        tmpchk = true;
      } else {
        tmpchk = false;
      }
    } else { 
      tmpchk = true;
    }
    chk = tmpchk && chk;
  }

  if(chk){
    cout << "APPROVED" << endl;
  } else { 
    cout << "DENIED" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  int h = 0;
  bool ans = true;
  vector<int> boxes;
  cin >> N;
  boxes.reserve(N);
  cin >> h;
  boxes.push_back(h-1); // boxes[0] == h  
  for (int i = 1; i < N; i++) {
    cin >> h;
    boxes.push_back(h); // boxes[i] == h
    
    // boxes[i]がboxes[i-1]より小さい場合はans=false
    if (boxes[i] == boxes[i-1]) {
      continue;
    } else if (boxes[i] < boxes[i-1]) {
      ans = false;
      break;
    }
    // boxes[i]がboxes[i-1]より大きいか同じ場合はboxes[i]を最大２減らす
    else if (boxes[i] > boxes[i-1]) {
      boxes[i]--;
    }
  }
  cout << (ans?"Yes":"No") << endl;
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(0);
  int q = -1, r;
  while(q != 0) {
    q = n / k;
    r = n % k;
    x.push_back(r);
    n = q;
  }
  cout << x.size() << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
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 (b < a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
const ll MOD = 1000000007;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
vector<ll> dx={0,1};
vector<ll> dy={1,0};
int main(){
    ll n;cin>>n;
    vector<double> p(n);
    rep(i,n)cin>>p[i];
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    dp[0][0]=1;
    rep(i,n){
        rep(j,n){
            dp[i+1][j]+=dp[i][j]*(1-p[i]);
            dp[i+1][j+1]+=dp[i][j]*p[i];
        }
    }
    double res = 0;
    REP(i,(n+1)/2,n+1){
        res+=dp[n][i];
    }
    cout<<fixed << setprecision(10)<<res<<endl;
}


Measured memory_bytes: 70784
x = input()
list1 = x.split()
[r, c] = list1
r = int(r)
c = int(c)
list3 = []
list4 = []
for i in range(0, r):
    y = input()
    list2 = y.split()
    list2_i = [int(s) for s in list2]
    list3.append(list2_i)

for i in range(0, r):
    s = sum(list3[i])
    list3[i].append(s)

for p in range(0, c):
    z = 0
    
    for q in range (0, r):
        z = z + list3[q][p]
     
    list4.append(z)

s = sum(list4)
list4.append(s)

list3.append(list4)

for i in range(0, r + 1):
    list3[i] = [str(s) for s in list3[i]]

for i in range(0, r + 1):
    mojiretsu = " ".join(list3[i])
    print(mojiretsu)


Measured memory_bytes: 6212
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	int c = a + b;
	println((c % 2 == 0 ? to_string(c / 2) : "IMPOSSIBLE"));
}

Measured memory_bytes: 256
#include<cstdio>
inline int min(int x,int y){return x<y?x:y;}
int n,dp[600000],next[600000];
char s[600000];
int main()
{
	scanf("%d%s",&n,s);
	for(int i=1;i<=n;i++)dp[i]=n;
	int tot=0;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='1')tot++;
		if(s[i]=='0')next[i]=i;
		else if(i+1<n)next[i]=next[i+1];
		else next[i]=n;
	}
	for(int i=0;i<n;i++)
		if(s[i]=='0')dp[i+1]=min(dp[i+1],dp[i]);
		else
		{
			dp[i+1]=min(dp[i+1],dp[i]+1);
			if(next[i]==i+1)for(int j=i+2;j<n;j++)
			{
				if(s[j]=='0')break;
				dp[j+1]=min(dp[j+1],dp[i]+1);
			}
			else if(next[i]+1<n&&s[next[i]+1]=='1')dp[next[i]+2]=min(dp[next[i]+2],dp[i]+1);
		}
	printf("%d\n",tot-dp[n]);
	return 0;
}


Measured memory_bytes: 5120
# 計算量 O(NC) = O(3 * 10 ** 6)
import sys
input = sys.stdin.readline
import numpy as np

N, C = map(int, input().split())

# 入力
lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]
lst_max = [[1] * (10 ** 5 + 10) for _ in range(C + 1)]

# lst = [[0] * (10) for _ in range(C + 1)]
# lst_max = [[1] * (10) for _ in range(C + 1)]

for _ in range(N):
    s, t, c = map(int, input().split())
    lst[c][s] += 1
    lst[c][t + 1] -= 1

lst = np.array(lst)
np.cumsum(lst, axis = 1, out = lst)
np.minimum(lst, lst_max, out = lst)
np.cumsum(lst, axis = 0, out = lst)

print (np.max(lst[-1]))

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

int main() {
  int N;
  cin >> N;
  string ans = "No";
  while(N>0) {
    int r = N%10;
    if (r==7) {
      ans = "Yes";
    }
    N /= 10;
  }

  cout << ans;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  int k, i;
  unsigned long long int a[100000], max=2, min=2;
  scanf("%d",&k);
  for(i=0;i<k;i++) scanf("%lld",&a[i]);
  for(i=0;i<k;i++){
    if(max<a[k-i-1]) break;
    if(max-max%a[k-i-1]<min) break;
    max=max-max%a[k-i-1]+a[k-i-1]-1;
    if(min<a[k-i-1]) min=a[k-i-1];
    else if(min%a[k-i-1]!=0) min=min-min%a[k-i-1]+a[k-i-1];
    //printf("%d,%d...",min,max);
  }
  if(i!=k || a[k-1]!=2) printf("-1\n");
  else printf("%lld %lld\n",min, max);
  return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

ll mod_pow(ll x, ll n, ll mod){
    ll v = 1;
    for(; n; x=x*x%mod, n>>=1)
        if(n & 1) v = v * x % mod;
    return v;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    string s; cin >> s;
    int n = s.size();

    vvl dp(s.size()+1, vl(13));
    dp[0][0] = 1;
    rep(i,n){
        ll m = mod_pow(10, i, 13) % 13;
        if(s[n-1-i] == '?'){
            rep(c,10) rep(j,13){
                ll rem = c * m % 13;
                dp[i+1][(j+rem)%13] += dp[i][j];
                dp[i+1][(j+rem)%13] %= mod;
            }
        }else{
            int c = s[n-1-i] - '0';
            rep(j,13){
                ll rem = c * m % 13;
                dp[i+1][(j+rem)%13] += dp[i][j];
                dp[i+1][(j+rem)%13] %= mod;
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 13648
n = int(input())
a = list(map(int,input().split()))
r = []
b = 0

for j in range(1,n+1):
    if j%2 == 1:
        b += a[j-1]
    else:
        b -= a[j-1]
r.append(b)

for i in range(2,n+1):
    r.append(2*a[i-2] - r[-1])
print(' '.join(list(map(str,r))))

Measured memory_bytes: 19144
import itertools

N, M, Q = map(int, input().split())
q_list = []
for i in range(Q):
    q = list(map(int, input().split()))
    q_list.append(q)
l = []
for i in range(1,M+1):
    l.append(i)
A_list = list(itertools.combinations_with_replacement(l, N))
ans = 0

for A in A_list:
    s = 0
    for q in q_list:
        if A[q[1]-1] - A[q[0]-1] == q[2]:
            s += q[3]
    if s > ans:
        ans = s

print(ans)


Measured memory_bytes: 84388
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int main() {
    io;
    // freopen("in","r",stdin); 
    // freopen("out","w",stdout);
    
    int n;
    cin>>n;
    map<int, int> time;
    int sum  = 0;

    rep(i,0,n){
        cin>>time[i+1];
        sum+=time[i+1];
    }
    int m;
    cin>>m;
    rep(i,0,m){
        int p,tt;
        cin>>p>>tt;
        cout<<sum-time[p] +tt<<endl;

    }

 
    
 
    
 
    return 0;
}

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

#include<iostream>
#include<queue>


using namespace std ;


#define y .first
#define x .second


pair< int ,int > p ,cpy ;


char route[ 1000 + 1 ][ 1000 + 1 ] ;

int came[ 1000 + 1 ][ 1000 + 1 ] ;


bool check( pair< int ,int > now,int h,int w ) ;

#define size sizeof came


int mx[] = { 1 ,0 ,0 ,-1 } ;
int my[] = { 0 ,1 ,-1 ,0 } ;


int main()
{
	int h ,w ,n ;
	scanf( "%d %d %d" ,&h ,&w ,&n ) ;

	char end = '0' + n ,cheese = '1' ;

	scanf( "%c" ,&route[ 0 ][ 0 ] ) ;

	int i ,j ;
	for( i = 0 ; i < h ; ++i )
	{
		for( j = 0 ; j <= w ; ++j )
		{
			scanf( "%c" ,&route[ i ][ j ] ) ;

			if( route[ i ][ j ] == 'S' )
			{
				p y = i ;
				p x = j ;
			}
		}
	}

	int ans = 0 ;
	
	do
	{
		queue< pair< int ,int > > que ;

		memset( came ,0 ,size ) ;

		while( route[ p y ][ p x ] != cheese )
		{
			int i ;
			for( i = 0 ; i < 4 ; ++i )
			{
				cpy y = p y + my[ i ] ;
				cpy x = p x + mx[ i ] ;

				if( route[ cpy y ][ cpy x ] != 'X' && check( cpy ,h ,w ) == true )
				{
					came[ cpy y ][ cpy x ] = came[ p y ][ p x ] + 1 ;

					que.push( cpy ) ;
				}
			}

			came[ p y ][ p x ] = 1 ;

			p = que.front() ;

			que.pop() ;
		}

		++cheese ;

		ans += came[ p y ][ p x ] ;

	}while( cheese <= end ) ;

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


	return 0 ;
}


bool check( pair< int ,int > now ,int h ,int w )
{
	if( now y >= h || now x >= w || now y < 0 || now x < 0 )
		return false ;

	else if( came[ now y ][ now x ] > 0 )
		return false ;

	return true ;
}

Measured memory_bytes: 8180
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
using namespace std;
int main(){
    char s[10];
    scanf("%s", s);
    if(s[2]==s[3] && s[4]==s[5]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    V<P> A(n);
    loop (n, i) {
        int a, b; cin >> a >> b;
        A[i] = { b, a };
    }
    sort(A.begin(), A.end());

    ll crr = 0;
    loop (n, i) {
        crr += A[i].second;
        if (crr > A[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int N; 
cin >> N; 
if(N < 105) cout << 0 << endl;  
else if(N < 135) cout << 1 << endl; 
else if(N < 165) cout << 2 << endl; 
else if(N < 189) cout << 3 << endl; 
else if(N < 195) cout << 4 << endl; 
else if(N < 201) cout << 5 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
		char x[19];
		for(int i=0;i<19;i++)
			cin>>x[i];
		for(int i=0;i<19;i++){
			if(x[i]==',')
				cout<<' ';
			else
				cout<<x[i];
		}	
	 return 0;
	 }

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

using namespace std;

int main(){
   int a,b,c;
   cin>>a;
   cin>>b;
   cin>>c;
   getchar();
   if(a+b+c<22){
      cout<<"win"<<endl;
   }
   else{
      cout<<"bust"<<endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    string s;
    cin >> s;
    rep(i,s.size()) if(s[i]=='?') s[i]='D';
    cout << s << endl;
}

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

long N, A[10010];
long min() {
	long m = A[0];
	for(long i=0;i<N;i++){
		if(A[i]<m)
			m = A[i];
	}
	return m;
}

long max() {
	long M = A[0];
	for(long i=0;i<N;i++){
		if(A[i]>M)
			M = A[i];
	}
	return M;
}

long sum() {
	long s = 0;
	for(long i=0;i<N;i++)
		s += A[i];
	return s;
}
int main() {
	cin >> N;
for (long i=0; i<N; ++i)
	cin >> A[i];
cout << min() << " " << max() << " " << sum() << endl;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A[3];
int main(){
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<3;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  sort(A,A+3);
  if(A[0]+A[1]==A[2]){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A[3];
// {
//   rd(A(3));
//   sort(A,A+3);
//   wt( if[A[0]+A[1]==A[2], "Yes", "No"] );
// }


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static int mod = 1000000007;
    public static long[][] multiply(long arr1[][] , long arr2[][]){
        long ans[][] = new long[arr1.length][arr2.length];

        for(int i = 0 ; i < arr1.length ; i++){
            for(int j = 0 ; j < arr2.length ; j++){
                for(int k = 0 ; k < arr1.length ; k++){
                    ans[i][j] = (ans[i][j] + arr1[i][k]*arr2[k][j]) % mod;
                }
            }
        }
        return ans;
    }
    public static long[][] power(long arr[][] , long k){
        if(k == 1){
            return arr;
        }
        long res[][] = power(arr , k/2);
        if(k%2 == 0){
            return (multiply(res , res));
        }else{
            return (multiply(arr , multiply(res , res)));
        }
    }
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        long k = s.nextLong();
        long arr[][] = new long[n][n];
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < n ; j++){
                arr[i][j] = s.nextLong();
            }
        }
        long dp[][] = power(arr , k);

        long ans = 0;
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < n ; j++){
                ans = (ans + dp[i][j])%mod;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 42292
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
//#include "debug.cpp"

int32_t main()
{
	boost;
	
   int n;
   cin>>n;
   int a[n+1];
   int ans=0;
   for(int i=1;i<=n;i++){
   	cin>>a[i];
   }
   int p[n+1];
   p[1]=a[1];
   for(int i=2;i<=n;i++){
   	p[i]=min(p[i-1],a[i]);
   }
   for(int i=1;i<=n;i++){
   	if(p[i]==a[i])
   		ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3328
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	int W = -1, S = -1;
	for (int i = 0; i * 100 * a <= f; i++) {
		for (int j = 0; j * 100 * b <= f; j++) {
			for (int k = 0; k * c <= f; k++) {
				for (int l = 0; l *d <= f; l++) {
					int wat = 100 * a * i + 100 * b * j;
					int sug = c *k + d * l;
					if (sug + wat > f) continue;
					if (wat == 0) continue;
					if (100 * sug > e * wat) continue;
					if (W == -1) {
						W = wat, S = sug;
						continue;
					}
					if (S * wat < sug * W) {
						S = sug;
						W = wat;
					}
				}
			}
		}
	}
	printf("%d %d\n", S + W, S);
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n,m;cin>>n>>m;
    ll res = min(n,m/2);
    n -= res;
    m -= res*2;
    if(n == 0){
        n += m/4;
        m -= n*2;
        res += min(n,m/2);
    }
    out(res);
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 8
#define exsit -1
#define nexsit 1
#define true 1
#define false 0

int row[N],col[N],lslan[2*N-1],rslan[2*N-1],a[N][N];

//初期化
void initialize(){
  int i;

  for(i=0;i<N;i++){
    row[i]=col[i]=exsit;
  }

  for(i=0;i<2*N-1;i++){
    lslan[i]=rslan[i]=exsit;
  }
}

void print(){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(a[i][j] && row[i]!=j) return;   //指定されたところにクイーンがない場合、やり直し
    }
  }

  for(i=0;i<N;i++){             //指定されたところにクイーンがある場合、表示
    for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void position(int i){
  int j;

  if(i==N){
    print();
    return;
  }

 //クイーンが他のクイーンい襲撃されている場合は無視する
  for(j=0;j<N;j++){
    if(col[j]==nexsit || lslan[i+j]==nexsit || rslan[i-j+N-1]==nexsit ) continue;


    //クイーンを配置する
    row[i]=j;
    col[j]=lslan[i+j]=rslan[i-j+N-1]=nexsit;

    //次の行に配置する
    position(i+1);

    //失敗した場合クイーンを取り除く
    row[i]=col[j]=lslan[i+j]=rslan[i-j+N-1]=exsit;
  }
}

int main(){
  int i,j,n,r,c;

  initialize();

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      a[i][j]=false;
    }
  }
   scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    a[r][c]=true;
  }

  position(0);

  return 0;
}




Measured memory_bytes: 2108
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        String T = scanner.nextLine();
        int count = 0;
        for (int i = 0; i < S.length(); i++) {
            if (T.charAt(i) != S.charAt(i)){
                count++;
            }
        }


        System.out.println(count);
    }
}


Measured memory_bytes: 42812
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
		int N;
		string s,t;
		cin>>N>>s>>t;
		int ans=2*N;
		int i=N-1;
  fx(N){
		if(s.substr(x)==t.substr(0,N-x)){
            ans-=N-x;
          break;
        }
		
  }
		ce(ans)
}


Measured memory_bytes: 256
n, m = map(int, input().split())
d = {}
c = "IMPOSSIBLE"

for i in range(1,n):
    if i == 1:
        d[i] = []
    else:
        d[i] = 0

for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        d[a].append(b)
    elif d[a] < b:
        d[a] = b

for k in d[1]:
    if d[k] == n:
        c = "POSSIBLE"

print(c)


Measured memory_bytes: 32472
package main

import (
	"fmt"
	"strings"
)

func main() {
	var S string
	fmt.Scan(&S)

	atcg := []string{"A", "T", "G", "C"}
	s := strings.Split(S, "")

	max := 0
	count := 0

	for _, v := range s {
		if contains(v, atcg) {
			count++
			if max < count {
				max = count
			}
		} else {
			count = 0
		}
	}

	fmt.Println(max)
}

func contains(s string, m []string) bool {
	for _, v := range m {
		if v == s {
			return true
		}
	}
	return false
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

ll S;
map<ll, ll> memo;

ll dfs(ll x) {
    if(S < x) return 0;
    if(S == x) return 1;
    ll res = 0;
    rep2(i, 3, S - 2) {
        ll temp = x + i;
        if(memo.count(temp) == 0) (res += dfs(temp)) %= MOD;
        else (res += memo[temp]) %= MOD;
    }
    memo[x] = res;
    return res;
}

int main(void) {
    cin >> S;
    if(S >= 3) {
        cout << 1 + dfs(0) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3756
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    Set<Integer> memo = new HashSet<>();
    memo.add(a);
    
    for (int i = 2; i < 1000000; i++) {
      a = a % 2 == 0 ? a / 2 : a * 3 + 1;
      if (memo.contains(a)) {
        System.out.println(i);
        break;
      } else {
        memo.add(a);
      }
    }
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

vector<int> g[100010];
bool used[100010];

int dfs(int now){
    used[now]=true;
    bool leaf=true;
    int white=0,yet=0;
    for(int i=0;i<g[now].size();i++){
        int next=g[now][i];
        if(used[next]) continue;
        leaf=false;
        int z=dfs(next);
        if(z==1) return 1;
        else if(z==0) white++;
        else yet++;
    }

    if(now==0){
        if(yet==1) return 0;
        else return 1;
    }else{
        if(yet>=2) return 1;
        else if(yet==1) return 0;
        else return -1;
    }
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++){
      int a,b;
      cin>>a>>b;
      a--;
      b--;
      g[a].push_back(b);
      g[b].push_back(a);
  }

  if(dfs(0)) cout<<"First"<<endl;
  else cout<<"Second"<<endl;

  return 0;
}


Measured memory_bytes: 7168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ab = br.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        System.out.println(problem106a(a, b));
    }

    private static int problem106a(int a, int b) {
        return (a - 1) * (b - 1);
    }
}

Measured memory_bytes: 23124
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int a;
   int b;
 
   cin >> a >> b;
   int n[a];
  
for(int i = 0;i<a;i++){
     
   cin >> n[i];
 
}
  
  int ans = 0;
  
  for(int i = 0;i<a;i++){
     
   if(n[i]>=b){
     ans++;
   }
 
}
  
   cout << ans << endl;
   
  return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}
#define int ll
void read() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (a >= b) {
		b *= 2;
		k--;
	}
	while (b >= c) {
		c *= 2;
		k--;
	}
	if (k >= 0) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3644
def solve(string):
    n, *ab = map(int, string.split())
    ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: (x[1], x[0]))
    past = 0
    for a, b in ab:
        past += a
        if past > b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 54024
#include<stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	if(b>=1 && b<=9) c = 10*a + b;
	else if(b>=10 && b<=99) c = 100*a + b;
	else if(b=100) c = 1000*a + 100;
	int i;
	for(i=1;i<=1100;i++){
		if(c == i*i){
			printf("Yes");
			goto YES;
		};
	};
	printf("No");
	YES:;
	
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();
        int cnt = 0;
        char befch = str.charAt(0);
        for (int i = 0; i < str.length(); i++) {
            if(befch!=str.charAt(i)){
                cnt++;
            }
            befch = str.charAt(i);
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 13340
#include<bits/stdc++.h>
using namespace std;
struct opr{
	int x;
	int y;
	int x1;
	int y1;
};
int main()
{
//	freopen("even.txt","r",stdin);
	vector<opr> ans;
	int mp[501][501];
	bool visit[501][501];
	memset(visit,1,sizeof(visit));
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>mp[i][j];
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w-1;j++)
		{
			if(mp[i][j]&1)
			{
				opr tmp;
				tmp.x=i;
				tmp.x1=i;
				tmp.y=j;
				tmp.y1=j+1;
				ans.push_back(tmp);
				mp[i][j]--;
				mp[i][j+1]++;
			}
		}
	}
	for(int i=1;i<=h-1;i++)
	{
		if(mp[i][w]&1)
		{
			opr tmp;
			tmp.x=i;
			tmp.x1=i+1;
			tmp.y=w;
			tmp.y1=w;
			ans.push_back(tmp);
			mp[i][w]--;
			mp[i+1][w]++;
		}
	}/*
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cout<<mp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)
	{
		cout<<ans[i].x<<" "<<ans[i].y<<" "<<ans[i].x1<<" "<<ans[i].y1<<endl;
	}
	return 0;
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define sz(a) ((ll)(a).size())
#define len(a) ((ll)(a).length())
#define F first
#define S second
#define vi vector <int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
#define nl cout<<"\n"
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// hashing for pairs
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
void solve()
{
  ll n;
  vl arr;
  cin>>n;
  inputv(arr,n);
  ll x=arr[0];
  for (ll i = 1; i < n; i++)
  {
     x^=arr[i];
  }
  for (ll i = 0; i < n; i++)
  {
    arr[i]^=x;
  }
  for (ll i = 0; i < n; i++)
  {
    cout<<arr[i]<<" ";
  }
  nl;
  return;
}
int main()
{
    IOS;
    int T=1;
   // cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;

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

long long solve(string str) {
  int s = 0, c = 0;
  vector<long long> v;
  rep (i, str.size()) {
    if (str[i] == '[') {
      if (c == 1) s = i;
      ++c;
    } else if (str[i] == ']') {
      --c;
      if (c == 1) v.push_back(solve(str.substr(s, i - s + 1)));
    }
  }
  if (v.empty()) {
    long long res = 0;
    for (int i = 1; i < (int)str.size() - 1; ++i) res = res * 10 + str[i] - '0';
    return res / 2 + 1;
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  rep (i, v.size() / 2 + 1) ans += v[i];
  return ans;
}

int main() {
  int t;
  cin >> t;
  rep (_, t) {
    string s;
    cin >> s;
    cout << solve(s) << endl;
  }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
  int N; ll M; cin >> N >> M;
  COMinit();
  auto x = prime_factor(M);
  ll cnt = 0;
  ll ans = 1;
  for(auto m : x) {
    cnt = m.second;
    ll tmp = COM(cnt + N - 1, N - 1);
    ans = (ans * tmp) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5120
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll h,w; cin >> h >> w; ll blackcnt = 0; ll INF = 1e7;
  vector<vector<char>> table(h,vector<char>(w));
  vector<vector<ll>> cnt(h,vector<ll>(w,INF));
  cnt[0][0] = 1;
  
  
  rep(i,h){
    rep(j,w){
      char c; cin >> c;
      table[i][j] = c;
      if(c == '#') blackcnt++;
    }
  }
  
  queue<pair<ll,ll>> q;
  q.push(make_pair(0,0));
  
  ll dx[] = {0,0,1,-1}; ll dy[] = {1,-1,0,0};
  
  
  while(!q.empty() and cnt[h-1][w-1] == INF){
    auto p = q.front();
    q.pop();
    ll nowh = p.first; ll noww = p.second;
    
    rep(i,4){
      ll gox = noww+dx[i]; ll goy = nowh+dy[i];
      
      if(0 <= goy and goy <= h-1 and
         0 <= gox and gox <= w-1 and
         table[goy][gox] == '.' and
         cnt[goy][gox] == INF){
        cnt[goy][gox] = cnt[nowh][noww] + 1;
        q.push(make_pair(goy,gox));
      }
    }
    
  }
  
  if(cnt[h-1][w-1] == INF) cout << -1 << endl;
  else cout << h*w - blackcnt - cnt[h-1][w-1] << endl;

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' ';pr(b);}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' ';pr(b,c);}
template<C T,C T2,C T3,C T4>void pr(T a,T2 b,T3 c,T4 d){cout<<a<<' ';pr(b,c,d);}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  rep(i,n) {
    rep(j,n-i) {
      if(s[i+j]!=t[j]) goto next;
    }
    pr((s.substr(0,i)+t).size());
    return;
  next:;
  }
  pr((s+t).size());
}

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


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MAX_N 100
#define MAX_W 10000

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int dp[MAX_N+1][MAX_W+1];
int N, W, v[MAX_N], w[MAX_N];

int main(){
  scanf("%d%d", &N, &W);
  rep(i, N) scanf("%d%d", v+i, w+i);

  rep(i, N) rep(j, W+1){
    if(j < w[i]) dp[i+1][j] = dp[i][j];
    else dp[i+1][j] = max(dp[i][j], dp[i+1][j - w[i]] + v[i]);
  }
  printf("%d\n", dp[N][W]);
  return 0;
}

Measured memory_bytes: 5096
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys

def read_data():
    lines = [line.rstrip() for line in sys.stdin]
    ns = [int(n) for n in lines[1].split()]
    ms = [(int(line.split()[0]), int(line.split()[1])) for line in lines[3:]]
    return ns, ms

def main():
    ns, ms = read_data()
    for (drink_num, drink_sec) in ms:
        result = sum(ns) - ns[drink_num-1] + drink_sec
        print result


if __name__ == "__main__":
    main()


Measured memory_bytes: 2568