akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class PaizaPj
{
    public static void Main()
    {
        // 読込
        string S = Console.ReadLine().Trim();
        string T = Console.ReadLine().Trim();

        if (T.Remove(S.Length).Equals(S))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 25860
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

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

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

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    int N;
    cin >> N;
    vector<LL> a(N);
    for (int i = 0; i < N; i++) cin  >> a[i];
    sort(a.begin(), a.end());
    LL res = 0;
    for (int i = 0; i < (N-2)/2; i++) res += 2*(i+1)*(a[i+1]-a[i]);
    // dbg_var(res);
    for (int i = 0; i < (N-2)/2; i++) res += 2*(i+1)*(a[N-1-i]-a[N-2-i]);
    // cout << res << "\n";
    if (N % 2) {
        res += (N-2)*(a[N/2]-a[N/2-1]);
        res += (N-2)*(a[N/2+1]-a[N/2]);
        res += max(a[N/2+1]-a[N/2], a[N/2]-a[N/2-1]);
    } else {
        res += (N-1)*(a[N/2]-a[N/2-1]);
    }
    cout << res << "\n";
}


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


long long calc(long i){
    long long cnt1=(i+1)/2;
    long long cnt2=cnt1%2;

    long long ans;
    //cout<<cnt2<<endl;
    if((i+1)%2) return i^cnt2;
    else return cnt2;
}


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

    cout<<(calc(a-1)^calc(b))<<endl;
    return 0;

}


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

using namespace std;

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

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

  int ans = 0;
  int right = 0;
  for (int left = 0; left < n; left++) {
    while (right < n && a[right] - a[left] <= 2) {
      right++;
    }
    ans = max(ans, right - left);
    if (left == right) {
      right++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
/*
 * Be careful of overflow
 * Array bounds
 * Assert a!=0 when performing x/a
 * Check base condition for recursion
 * Iterator -> O(1), Element -> O(log n) while using erase
 * 1LL<<x when x>32
 * Be sure of what you are going to code (exception dp)
 * Don't try fancy tricks during contest
 * You can always make a bad round to a good enough round
 */ 

int a[200009];

void solve()
{
	int n,i;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	
	int maxx=a[0];
	ll sum=0;
	for(i=1;i<n;i++)
	{
		if(a[i]<maxx)
		{
			sum+=maxx-a[i];
		}
		maxx=max(maxx,a[i]);
	}
	cout<<sum<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 4400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define DEBUG
#ifdef DEBUG
#define debug(...) __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
#define debug(...)
#endif
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}
 
#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"
 
// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;
 
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

const int MAXN = 2e5 + 5;

ll n, a[MAXN], k;

bool check(ll x)
{
	if(!x) return false;
	ll tot = 0;
	for(int i=0;i<n;i++) tot += (a[i] - 1) / x;
	if(tot <= k) return true;
	return false;
}

ll bs(ll start, ll end)
{
	ll mid = (start + end) / 2;
	bool f1 = check(mid);
	bool f2 = check(mid - 1);
	if(f1 && !f2) return mid;
	else if(f2) end = mid - 1;
	else start = mid + 1;
	return bs(start, end);
}

int main()
{
	FAST_IO;
 
 	cin >> n >> k;
 	for(int i=0;i<n;i++) cin >> a[i];
 	cout << bs(1, 1e9) << endl;
    return 0;
}

Measured memory_bytes: 5208
// AOJ 3129 Contest T-shirts
// 2020.1.16 bal4u

#include <stdio.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MIN(a,b) ((a)<=(b)?(a):(b))

int main()
{
	int M, N, a0;
	
	M = in(), N = in();
	if (M == 2) {
		a0 = 1;
		int s1 = 0, s2 = 0;
		while (N--) {
			int a = in();
			if (a == a0) ++s1; else ++s2;
			a0 = 3 - a0;
		}
		printf("%d\n", MIN(s1, s2));
	} else {
		a0 = 0;
		int s = 0, f = 0;
		while (N--) {
			int a = in();
			if (!f) {
				if (a == a0) ++s, f = 1;
			} else f = 0;
			a0 = a;
		}
		printf("%d\n", s);
	}
	return 0;
}



Measured memory_bytes: 2056
n, y = list(map(int, input().split()))

ok = False
for i in range(n + 1):
    for j in range(n + 1):
        k = n - i - j
        if k < 0:
            continue
        if 10000 * i + 5000 * j + 1000 * k == y:
            print("%d %d %d" % (i, j, k))
            ok = True
            break
    if ok:
        break

if not ok:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N; cin >> N;
    vector<int> L(N);

    rep(i,N){
        cin >> L[i];
    }

    sort(L.begin(), L.end());

    int ans=0;
    for (int i=N-1; i>=2; i--){
        for(int j=i-1; j>=1; j--){
            auto itr
            = upper_bound(L.begin(), L.begin()+j, L[i]-L[j]);
            ans+=((L.begin()+j)-itr);
        }
    }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

int main(void){
    int N; cin >> N;
    int prime[1010] = {};
    
    for(int n = 2; n <= N; n++){
        int num = n;
        for(int j = 2; j * j <= num; j++){
            while(num % j == 0){
                num /= j;
                prime[j]++;
            }
        }
        if (num != 1) prime[num]++;
    }
    
    ll ans = 1;
    for(int i = 0; i < N+1; i++){
        // cout << prime[i] + 1 << endl;
        ans *= (prime[i] + 1);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
    /*static class Fast
    {
        BufferedReader br;
        StringTokenizer st;
 
        public Fast()
        
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }*/
    public static void main(String args[] ) throws Exception {
        //Fast in=new Fast();
        Scanner in=new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out); 
	    int n=in.nextInt(),m=in.nextInt();
	    in.nextLine();
	    char arr[][]=new char[n][m];
	    for(int i=0;i<n;i++){
	        String str=in.nextLine();
	        char[] ar=str.toCharArray();
	        for(int j=0;j<m;j++){
	            arr[i][j]=ar[j];
	        }
	    }
	    for(int i=0;i<n;i++){
	        for(int j=0;j<m;j++){
	            if(arr[i][j]=='#')continue;
	            else{
	                arr[i][j]=find(arr,i,j);
	            }
	        }
	    }
	    for(int i=0;i<n;i++){
	        for(int j=0;j<m;j++){
	            out.print(arr[i][j]);
	        }
	        out.println();
	    }
	    
	    
        out.close();
    }
    public static char find(char[][]arr,int i,int j){
        int c=0,n=arr.length,m=arr[0].length;
        if(i-1>=0 && j-1>=0 &&arr[i-1][j-1]=='#')c++;
        if(i-1>=0 && arr[i-1][j]=='#')c++;
        if(i-1>=0 && j+1<m &&arr[i-1][j+1]=='#')c++;
        if(j-1>=0 && arr[i][j-1]=='#')c++;
        if(j+1<m && arr[i][j+1]=='#')c++;
        if(i+1<n && j-1>=0 && arr[i+1][j-1]=='#')c++;
        if(i+1<n && arr[i+1][j]=='#')c++;
        if(i+1<n&&j+1<m&&arr[i+1][j+1]=='#')c++;
        return((""+c).charAt(0));
    }
}



Measured memory_bytes: 21716
#include <stdio.h>
const int N=1e2+10;
bool ans[N][N],went[N][N];
int a[N];
bool dp(int l,int r){
    if(l-r==1)return true;
    else if(r<l)return false;
    if(went[l][r])return ans[l][r];
    went[l][r]=true;
    if(r==l)return ans[l][r]=false;
    else if(r-l==1)return ans[l][r]=a[l]==a[r];
    else if(r-l==2)return ans[l][r]=a[l]==a[l+1]&&a[l]==a[r];
    else{
        for(int i=l;i<=r;i++)for(int j=i+1;j<=r;j++)if(a[i]==a[j]){
            ans[l][r]=dp(l,i-1)&&dp(i+1,j-1)&&dp(j+1,r);
            if(ans[l][r])return true;
        }
        for(int i=l;i<=r;i++)for(int j=i+1;j<=r;j++)if(a[i]==a[j])for(int k=j+1;k<=r;k++)if(a[j]==a[k]){
            ans[l][r]=dp(l,i-1)&&dp(i+1,j-1)&&dp(j+1,k-1)&&dp(k+1,r);
            if(ans[l][r])return true;
        }
        return ans[l][r]=false;
    }
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++)for(int j=i;j<n;j++)went[i][j]=false;
    if(dp(0,n-1))printf("yes\n");
    else printf("no\n");
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long s,ans,ft[2222],inv[2222];
long long pw(long long a,long long b)
{
	long long rt=1;
	while(b)
	{
		if(b&1)
		{
			rt*=a;
			rt%=md;
		}
		b>>=1;
		a*=a;
		a%=md;
	}
	return rt;
}
long long C(long long a,long long b)
{
	if(a==0)
	{
		return 1;
	}
	if(b==0)
	{
		return 1;
	}
	return ft[a]*inv[a-b]%md*inv[b]%md;
}
int main()
{
	ft[0]=1;
	ft[1]=1;
	for(int i=2;i<=2000;i++)
	{
		ft[i]=ft[i-1]*i*1ll%md;
	}
	inv[0]=1;
	inv[1]=1;
	for(int i=2;i<=2000;i++)
	{
		inv[i]=pw(ft[i],md-2);
	}
	cin>>s;
	for(int i=1;i<=s;i++)
	{
		s-=2*i;
		if(s<=i-1)
		{
			break;
		}
		ans+=C(s-1,i-1);
//		cout<<ans<<endl;
		ans%=md;
		s+=2*i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i = a;i <= b;++i)
using namespace std;
int main(){
	long long n,m = 0;
	cin>>n;
	fr(i,1,n - 1)m += i;
	cout<<m;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
a b c
 */
int a[3];

int main(){
  int ans=0;
  REP(i,3){
    cin >> a[i];
    bool f = true;
    REP(j,i){
      if(a[i]==a[j])
        f = false;
    }
    if(f)
      ans++;
  }
  cout <<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
     
#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())
#define	endl			'\n'
     
typedef long long		ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>		vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>		vpii;
     
const int MX = 25;
     
int main(int argc, char *argv[])
{
#ifdef	HTRINH_UNIT_TEST
	freopen(argv[1],"r",stdin);
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ios :: sync_with_stdio(false);
	cin.tie(NULL);

	int H,W;
	cin >> H >> W;
	char g[H][W];
	FOR(i,0,H) FOR(j,0,W) cin >> g[i][j];
	int p[H][W];
	FOR(i,0,H) FOR(j,0,W) p[i][j] = 0;;
	p[0][0] = 1;
	FOR(i,0,H) FOR(j,0,W) {
		if (!(i == 0 && j == 0) && g[i][j] == '.') {
			int fromLeft = 0;
			if (j-1 >= 0) fromLeft = p[i][j-1];
			int fromAbove = 0;
			if (i-1 >= 0) fromAbove = p[i-1][j];
			p[i][j] = ((ull)fromLeft+fromAbove)%1000000007;
		}
	}
    cout << p[H-1][W-1] << endl;
    return 0;
}


Measured memory_bytes: 5120
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

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

int main(void) {
    int n;
    cin >> n;
    vector<vector<P>> shougen(n);
    REP(i,n) {
        int a;
        cin >> a;
        REP(j,a) {
            int x, y;
            cin >>  x >> y;
            x--;
            shougen[i].push_back(make_pair(x,y));
        }
    }

    int ans = 0;

    for(int bit = 0; bit < (1 << n); ++bit) {
        map<int, bool> shoujiki;
        int tmp = 0;
        for(int i = 0; i < n; ++i) {
            if(bit & (1 << i)) {
                shoujiki[i] = true;
                tmp++;
            }else{
                shoujiki[i] = false;
            }
        }
        bool flag = true;
        REP(i,n) {
            if(shoujiki[i]) {
                for(auto v : shougen[i]) {
                    if(shoujiki[v.first] != v.second) {
                        flag = false;
                    }
                }
            }
        }
        if(flag) {
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
vector<int>v[1000005];
void solve() {
    int n;
    cin >> n;
    for (int i = 0 ; i < n ; i++) {
        int x;
        cin >> x;
        v[x].pb(i + 1);
    }
    int ans = 0;
    for (int i = 1 ; i <= 1000000 ; i++) {
        if (v[i].size() == 0)continue;
        if (v[i].size() == 1) {
            ans++;
        }
        for (int j = i * 2 ; j <= 1000000 ; j += i) {
            v[j].clear();
        }
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 33204
#include<stdio.h>
#include<string.h>
int main()
{
    int m,n,j,i,k,z,t;
    char a[100],b[100];
    while(scanf("%s%s",a,b)!=EOF)
    {	t=strlen(a);
    	for(i=0;i<t;i++)	
		{k=1;
		for(j=t;j>0;j--)
    	a[j]=a[j-1];
    	a[0]=a[t];
    	for(z=1;z<t+1;z++)
    	if(a[z]!=b[z-1])
    	{
	    	k=0;break;
	    }
	    if(k)
    	{printf("Yes\n");break;}
	}
	if(k==0)
	printf("No\n");
	}
	return 0;
}

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

using namespace std;
const int N = 1e3 + 3;
queue<int> q[N];
int vis[N], visID;
vector<pair<int, int>> match;
void check(int i, vector<pair<int, int>> &match) {
	if (q[i].empty())
		return;
	int j = q[i].front();
	if (q[j].size() && q[j].front() == i)
		match.emplace_back(i, j);
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	match.reserve(n * n);
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j < n; ++j) {
			int a;
			scanf("%d", &a);
			q[i].push(--a);
		}
		check(i, match);
	}
	int res = 0;
	while (true) {
		++visID;
		bool in = false;
		vector<pair<int, int>> tmp;
		for (auto &p: match) {
			int i = p.first, j = p.second;
			if (vis[i] != visID && vis[j] != visID) {
				vis[j] = vis[i] = visID;
				q[i].pop();
				q[j].pop();
				check(i, tmp);
				check(j, tmp);
				in = true;
			}else {
				tmp.push_back(p);
			}
		}
		tmp.swap(match);
		if (!in)
			break;
		++res;
	}
	for (int i = 0; i < n; ++i) {
		if (q[i].size()) {
			puts("-1");
			return 0;
		}
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 4736
# print("S=")
S = input()
# print("Q=")
Q = int(input())

def problem_gksn(S,Q):
  check_reverse = 0 # 偶数のとき正常, 奇数の時反転
  atama = ""
  oshiri = ""
  for _ in range(Q):
    # print("queryを入力してください")
    query = input().split()
    # print("query= ",query)
    if len(query) == 1: #1の場合
      # print("文字を反転させます")
      check_reverse += 1
      # S = S[::-1]
    else: #2の場合
      # print("文字をくっつけます")
      if int(query[1]) == 2 - check_reverse % 2:
        oshiri += query[2]
      else:
        atama += query[2]
      # print("atama",atama)
      # print("oshiri",oshiri)
  S = atama[::-1] + S + oshiri
  if check_reverse % 2==1:
    S = S[::-1]
  
  return S

print(problem_gksn(S,Q))

Measured memory_bytes: 4112
# -*- coding: utf-8 -*-

def solve():
    N = int(input())
    A, B, C = [input() for _ in range(3)]
    res = sum(len({a,b,c})- 1 for a,b,c in zip(A,B,C))
    return str(res)
if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3060
#coding:utf-8
#1_7_B 2015.4.5
while True:
    n,x = map(int,input().split())
    if n == x == 0:
        break
    count = 0
    
    for i in range(1 , n + 1):
        for j in range(1 , n + 1):
            if (x - i - j) <= n and i < j < (x - i -j):
                count += 1
    print(count)

Measured memory_bytes: 6720
n = int(input())
problems = list(map(int,input().split()))
sum_time = sum(problems)
m = int(input())
out = []
for _ in range(m):
    key,time = map(int,input().split())
    out.append(sum_time-problems[key-1]+time)

for time in out:
    print(time)

Measured memory_bytes: 3060
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
//#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int a, b, c;

ll solve() {
	ll ans = 0;
	while (1) {
		if (a & 1 == 1 || b & 1 == 1 || c & 1 == 1)break;
		int aa = a;
		int bb = b;
		int cc = c;
		a = bb / 2 + cc / 2;
		b = aa / 2 + cc / 2;
		c = aa / 2 + bb / 2;
		ans++;
	}
	return ans;
}



int main() {
	cin >> a >> b >> c;
	if (a & 1 == 1 || b & 1 == 1 || c & 1 == 1) {
		cout << 0 << endl;
		return 0;
	}
	if (a == b && a == c) {
		cout << -1 << endl;
		return 0;
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
/*
#include "stdafx.h"
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<complex>

*/
#include<bits/stdc++.h>

#define X real()
#define Y imag()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define FastF freopen("in.txt","r",stdin); freopen("out.txt","w",stdout)
#define Fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0)
using ll = long long;
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vi::iterator vii;
typedef vector<ll> vl;
typedef vl::iterator vli;
typedef long double C;
typedef complex<C> P;
const int INF = 1e9 + 5;
const ll INFF = 1e18 + 5;
const int M = 1e9 + 7;
const double pi = acos(-1);

int main()
{
	//FastF;
	Fast;
	string s;
	int a;
	cin >> a;
	cin >> s;
	if (a < 3200) cout << "red\n";
	else cout << s << '\n';
	return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val boxes = Array(n) {Box(false, 1)}
    boxes[0].hasRed = true

    repeat(m) {
        val (x, y) = readLine()!!.split(" ").map { it.toInt()-1 }
        if (boxes[x].cnt > 0) {
            boxes[x].cnt -= 1
            boxes[y].cnt++

            if (boxes[x].hasRed) {
                boxes[y].hasRed = true
            }
            if (boxes[x].cnt == 0) {
                boxes[x].hasRed = false
            }
        }
    }

    println(boxes.count { it.hasRed })
}

data class Box(var hasRed: Boolean, var cnt: Int)

Measured memory_bytes: 64560
N = int(input())
A = list(map(int,input().split()))
if A.count(0) == 0:
    
    k = 1
    for i in range(N):
        k = k * A[i]
        if k >= 10 ** 18 + 1:
            k = -1
            break
else:
    k = 0
print(k)

Measured memory_bytes: 21640
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let (n, s): (usize, Vec<Vec<u8>>) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        let n = sc.next();
        (n, sc.strings_as_mat(n, |b| b))
    };
    let s = {
        let mut r = vec![Vec::with_capacity(2 * n); 2 * n];
        for i in 0..n {
            let l = &s[i];
            for &i in &[i, i, n + i, n + i] {
                r[i].extend_from_slice(l);
            }
        }
        r
    };
    let r = (0..n)
        .map(|a| {
            for i in 0..n {
                for j in 0..n {
                    if s[a + i][j] != s[a + j][i] {
                        return 0;
                    }
                }
            }
            n
        })
        .sum::<usize>();
    println!("{}", r);
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


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

const int Maxn = 200005, p = 1e9 + 7;
int n, m, ct, tmp_ct, x[Maxn], y[Maxn], a[Maxn];
pair <int, int> P[Maxn];
long long sum[Maxn];
vector <int> Ve[Maxn];
int lowbit(int x)
{
	return x & -x;
}
void add(int x, int y)
{
	for (int i = x; i <= tmp_ct + 1; i += lowbit(i))
		(sum[i] += y) %= p;
}
long long ask(int x)
{
	long long tmp = 0;
	for (int i = x; i; i -= lowbit(i))
		(tmp += sum[i]) %= p;
	return tmp;
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &x[i]);
	for (int i = 1; i <= m; i++)
		scanf("%d", &y[i]);
	for (int i = 1; i <= n; i++)
	{
		if (x[i] < y[1] || x[i] > y[m]) continue;
		int pos = upper_bound(y + 1, y + 1 + m, x[i]) - y;
		P[++ct] = make_pair(y[pos] - x[i], x[i] - y[pos - 1]);
	}
	sort(P + 1, P + 1 + ct);
	for (int i = 1; i <= ct; i++)
		a[2 * i - 1] = P[i].first, a[2 * i] = P[i].second;
	sort(a + 1, a + 1 + 2 * ct);
	tmp_ct = unique(a + 1, a + 1 + 2 * ct) - a - 1;
	for (int i = 1; i <= ct; i++)
	{
		P[i].first = lower_bound(a + 1, a + 1 + tmp_ct, P[i].first) - a;
		P[i].second = lower_bound(a + 1, a + 1 + tmp_ct, P[i].second) - a;
		Ve[P[i].first].push_back(P[i].second);
	}
	add(1, 1);
	for (int i = 1; i <= tmp_ct; i++)
	{
		int las = 0;
		for (vector <int> :: reverse_iterator it = Ve[i].rbegin(); it != Ve[i].rend(); it++)
			if (*it != las) add(*it + 1, ask(*it)), las = *it;
	}
	printf("%lld", ask(tmp_ct + 1));
	return 0;
}


Measured memory_bytes: 12288
#include<queue>
#include<iostream>
#include<string>
using namespace std;
class p {
public:
	int n;
	string k;
};
int main(void)
{
	int n;
	int q;
	queue<p>m;
	cin >> n>>q;
	for (int i = 0; i < n; i++) {
		p t;
		cin >> t.k >> t.n;
		m.push(t);
	}
	int time = 0;
	p j;
	while (!m.empty()) {
		j = m.front();
		if (j.n <= q) {
			m.pop();
			time += j.n;
			cout << j.k << " " << time<<endl;
		}
		else {
			m.pop();
			j.n -= q;
			time += q;
			m.push(j);
		}
	}
	return 0;
}


Measured memory_bytes: 6256
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

int N;
const int MAX_N = 200010;

int a[MAX_N];

struct node{
	int pos,val,flip;
	node(){flip=0;}
	node(int pos_,int val_,int flip_):pos(pos_),val(val_),flip(flip_){}
}tree[2][MAX_N*4];

struct RMQ{

#define LL (2*k+1)
#define RR (2*k+2)

	RMQ(int n){
		for(int i=0;i<4*MAX_N;i++)tree[0][i].val=tree[1][i].val=1e9;
		make(0,1,n,0);
		make(1,1,n,0);
	}

	void make(int mod,int s,int e,int k){
		if(s>e){
			return;
		}else if(s==e){
			tree[mod][k] = node(s,s%2==mod?a[s]:1e9,0);
		}else{
			int mid = (s+e)/2;
			make(mod,s,mid,LL);
			make(mod,mid+1,e,RR);
			up(mod,k);
		}
	}

	void up(int mod,int k){
		int f = tree[mod][k].flip;
		tree[mod][k].val = tree[f^mod][LL].val;
		tree[mod][k].pos = tree[f^mod][LL].pos;

		if(tree[mod][k].val > tree[f^mod][RR].val){
			tree[mod][k].val = tree[f^mod][RR].val;
			tree[mod][k].pos = tree[f^mod][RR].pos;
		}
	}

	void update(int mod,int x,int c,int s,int e,int k){
		if(s==e){
			tree[mod][k].val=c;
			return;
		}
		int mid = (s+e)/2;
		if(x<=mid){
			update(mod^tree[mod][k].flip,x,c,s,mid,LL);
		}else{
			update(mod^tree[mod][k].flip,x,c,mid+1,e,RR);
		}
		up(mod,k);
	}

	void invert(int L,int R,int s,int e,int k){
		if(e<L||R<s)return;
		if(L<=s&&e<=R){
			swap(tree[0][k],tree[1][k]);
			tree[0][k].flip = !tree[0][k].flip;
			tree[1][k].flip = !tree[1][k].flip;
			return;
		}else{
			int mid = (s+e)/2;
			invert(L,R,s,mid,LL);
			invert(L,R,mid+1,e,RR);
		}
		up(0,k);
		up(1,k);
	}

	node query(int mod,int L,int R,int s,int e,int k){
		if(e<L || R<s)return node(0,1e9,0);
		if(L<=s&&e<=R)return tree[mod][k];
		int mid = (s+e)/2;
		node z0 = query(mod^tree[mod][k].flip,L,R,s,mid,LL);
		node z1 = query(mod^tree[mod][k].flip,L,R,mid+1,e,RR);
		if(z0.val < z1.val)return z0;
		return z1;
	}


#undef LL
#undef RR
};

set<int> range;

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",&a[i]);
	}
	RMQ rmq(N);
	range.insert(1);
	range.insert(N+1);

	for(int i=0;i<N/2;i++){
		int l = rmq.query(1,1,N,1,N,0).pos;
		auto it = range.upper_bound(l);
		
		int r = rmq.query(0,l+1,(*it)-1,1,N,0).pos;
		range.insert(l);
		range.insert(r+1);

		rmq.update(1,l,1e9,1,N,0);
		rmq.update(0,r,1e9,1,N,0);
		rmq.invert(l,r,1,N,0);
		printf("%d %d",a[l],a[r]);
		if(i<N/2-1)printf(" ");
	}
	
	return 0;
}


Measured memory_bytes: 30464
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve() {
    int n, res = INT_MIN, c = 0, cc = 0;
    cin >> n;
    int f[n][10], p[n][11];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 10; j++){
            cin >> p[i][j];
        }
    }

    for(int i = 1; i < (1<<10); i++){
        cc = 0;
        for(int j = 0; j < n; j++){
            c = 0;
            for(int k = 0; k < 10; k++){
                if(((i>>k) & 1) && f[j][k]){ //1~1023を右シフトすると1のビットがいい感じにでてくる．それと&をとって全探索
                    c++;    //他の店と同じ曜日がいくつあるか
                }
            }
            cc += p[j][c];  //店の利益
        }
        res = max(res, cc);
    }
    cout << res << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
import math
mod = 10**9 + 7
x, y = map(int, input().split())

if (x+y)%3 != 0:
    print(0)
    exit()

if x == 0 or y == 0:
    print(0)
    exit()

X = max(x,y)
Y = min(x,y)

all_move = (X+Y)//3
diff = (X-Y)
y_move = (all_move - diff)//2


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

n = int(all_move)
r = int(y_move)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


print(cmb(n,r,mod))


Measured memory_bytes: 82512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

int n;
int all;
int pre[2 * MaxN + 5], last[MaxN + 5], other[2 * MaxN + 5];
int deep[MaxN + 5];
int path[MaxN + 5];
bool vis[MaxN + 5];
int tot;
void build(int x, int y)
{
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
}
void get_path(int x)
{
	path[++tot] = x;
	if(x == 1) return;
	int ed = last[x], dr;
	while(ed != -1) {
		dr = other[ed];
		if(deep[dr] < deep[x]){
			get_path(dr);
		}
		ed = pre[ed];
	}
}
void get_deep(int x, int fa)
{
	deep[x] = deep[fa] + 1;
	int ed = last[x], dr;
	while(ed != -1) {
		dr = other[ed];
		if(dr != fa)
			get_deep(dr, x);
		ed = pre[ed];
	}
}
void dfs(int x, int fa)
{
	int ed = last[x], dr;
	vis[x] = 1;
	while(ed != -1) {
		dr = other[ed];
		if(dr != fa) 
			dfs(dr, x);
		ed = pre[ed];
	}
}
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		all = -1;
		memset(last, -1, sizeof(last));
		for(int i = 1; i < n; i++) {
			int u, v;
			scanf("%d %d", &u, &v);
			build(u, v); build(v, u);
		}
		get_deep(1, 0);
		//for(int i = 1; i <= n; i++)
		//	printf("deep[%d] = %d\n", i, deep[i]);
		get_path(n);
		/*for(int i = 1; i <= tot; i++)
			printf("%d ", path[i]);
		printf("\n");*/
		dfs(path[tot / 2], path[tot / 2 + 1]);
		int cnt = 0;
		for(int i = 1; i <= n; i++)
			if(vis[i] == 1)
				cnt++;
		if(cnt >= (n - cnt)) printf("Snuke\n");
		else printf("Fennec\n");
	}
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long t,summ=0;
    cin>>t;
    for(long long i=1;i<=t;i++){
        if(i%3==0 && i%5==0)
            continue;
        else if(i%3==0)
            continue;
        else if(i%5==0)
            continue;
        else
            summ+=i;
    }
    cout<<summ;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
def pred(t, x, y):
    return x + y <= t and (x + y - t) % 2 == 0
result = True
t, x, y = 0, 0, 0
for _ in range(int(input())):
    nt, nx, ny = map(int, input().split())
    if not pred(nt - t, abs(nx - x), abs(ny - y)):
        result = False
        break
    t, x, y = nt, nx, ny
print(['No', 'Yes'][result])


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll M, K;
    cin >> M >> K;
    ll N = (1ll << M);
    vector<ll> res(2*N);
    if(M <=1 || K == 0){
    	if(K == 0){
    		REP(i, N){
    			res[2*i] = i;
    			res[2*i+1] = i;
    		}
    	}else{
    		cout << -1 << endl;
    		exit(0);
    	}
    }else{
    	if(K < N){
    		res[0] = 0;
    		res[2] = 0;
    		res[1] = K;
    		res[N+1] = K;
    		ll cnt = 0;
    		for(int i=1;i<N;i++){
    			if(i == K) continue;
    			res[3+cnt] = i;
    			res[2*N-1-cnt] = i;
    			cnt++;
    		}
    	}else{
    		cout << -1 << endl;
    		exit(0);
    	}
    }
    REP(i, 2*N) cout << res[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <tuple>

using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<int>> a(H, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> a[i][j];
		}
	}

	vector<tuple<int, int, int, int>> ans;

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j + 1 < W; ++j) {
			if (a[i][j] & 1) {
				--a[i][j];
				++a[i][j + 1];
				ans.emplace_back(i, j, i, j + 1);
			}
		}
	}
	for (int i = 0; i + 1 < H; ++i) {
		int j = W - 1;
		if (a[i][j] & 1) {
			--a[i][j];
			++a[i + 1][j];
			ans.emplace_back(i, j, i + 1, j);
		}
	}
	cout << ans.size() << endl;
	for (auto& e : ans) {
		int a, b, c, d;
		tie(a, b, c, d) = e;
		++a;
		++b;
		++c;
		++d;
		cout << a << " " << b << " " << c << " " << d << endl;
	}
}


Measured memory_bytes: 5232
n = int(input())
s = ""
for i in range(n):
  l = list(map(lambda x:x*x,map(int, input().split())))
  l.sort()
  if l[0] + l[1] == l[2]:
      s += "YES\n"
  else:
      s += "NO\n"

print(s,end="")

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

int main(){
	int n;cin>>n;
	vector<int>h(n);
	for(auto&& u:h)cin>>u;
	int ret=h[0];
	for(int i=0;i<n-1;i++){
		if(h[i+1]>h[i])ret+=h[i+1]-h[i];
	}
	cout<<ret<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,ans=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        if(v[i]==i+1){
            ans++;
            if(i+1!=n){
                swap(v[i],v[i+1]);
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define all(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  int N, M; cin >> N >> M;
  int L[M], R[M];
  rep(i,M){
    cin >> L[i] >> R[i];
  }
  int left = 1;
  int right = INF;
  int ans = 0;
  rep(i,M){
    left = max(L[i], left);
    right = min(R[i], right);
  }
  if (left<=right)  cout << right-left+1 << endl;
  else cout << 0 << endl;
  return 0;

}


Measured memory_bytes: 1024
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,m;

vector<pi> g[405];
typedef bitset<405> bs;
bs reach[405];

int vacT[405];
bool valid[405];
int main(){
  cin>>n>>m;
  REP(i,m){
    int a,b;cin>>a>>b;--a;--b;
    g[a].pb({b,i});
    g[b].pb({a,i});
  }
  REP(i,n){
    memset(vacT,-1,sizeof(vacT));
    vacT[i]=m;
    queue<int> q;q.push(i);
    valid[i]=true;
    while(!q.empty()){
      int cur=q.front();q.pop();
      for(auto e:g[cur]){
        if(e.sc>=vacT[cur]) continue;
        if(vacT[e.fr]==-1){
          vacT[e.fr]=e.sc;
          q.push(e.fr);
        }else{
          valid[i]=false;
          goto exi;
        }
      }
    }
    exi:;
    if(valid[i]){
      REP(j,n) if(vacT[j]!=-1) reach[i].set(j);
    }
  }
  int res=0;
  REP(i,n) REP(j,i) if(valid[i] && valid[j] && !((reach[i]&reach[j]).any())){
    ++res;
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

const int mod=1e9+7;
const int sz=200005;

int fact[sz],inv[sz],ifact[sz];

void make(){
    fact[0]=fact[1]=inv[1]=ifact[0]=ifact[1]=1;
    for(int i=2;i<sz;i++){
        fact[i]=fact[i-1]*i%mod;
        inv[i]=inv[mod%i]*(mod-mod/i)%mod;
        ifact[i]=ifact[i-1]*inv[i]%mod;
    }
}

int comb(int n,int k){
    if(n<k) return 0;
    return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
}

signed main()
{
    int N,M; cin>>N>>M;

    auto cnt=prime_factor(M);
    make();

    int ans=1;
    for(auto p:cnt){
        int k=p.second;
        ans*=comb(k+N-1,N-1);
        ans%=mod;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define N 505
using namespace std;

int n, m, used[N];
vector<int> G[N];

int dfs(int x){
  
  if(used[x]) return 0;
  used[x]=1;
  
  int res=0;

  for(int i=0;i<G[x].size();i++) res+=dfs(G[x][i]);
  
  return res+G[x].size()-1;
}

int main(){
  
  cin>>n>>m;
  
  for(int i=0;i<m;i++){
    int s, t;
    cin>>s>>t;
    G[s-1].push_back(t-1);
  }

  int ans=0;
  
  for(int i=0;i<n;i++)
    if(!used[i]) ans+=dfs(i)+1;
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define pb push_back


///Input/Output macros!
#define gi(x) scanf("%d", &x)
#define gi2(x, y) scanf("%d%d", &x, &y)
#define gi3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define gill(x) scanf("%lld", &x)
#define gill2(x, y) scanf("%lld%lld", &x, &y)
#define gill3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pill(x) printf("%lld\n", x)


///Basic Debugging macros!
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(ll __i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(ll __i__=0;__i__<r;__i__++){for(ll __j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}

using namespace std;

///Power of 2 till 2^31!
ll pow2[32] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648};

///Power function!
ll power(ll x,ll y)
{
        ll res = 1;
        while(y>0){
            if(y&1)
                res *= x;
            y>>=1;
            x*=x;
        }
        return res;
}

///Basic Sieve of Eratosthenes!
void Sieve(ll n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (ll p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

bool isPerfectSquare(ll x){ ll s = sqrt(x); return (s*s == x);}

bool isFibonacci(int n){return isPerfectSquare(5*n*n + 4) || isPerfectSquare(5*n*n - 4);}

bool isPrime(int n){if (n <= 1)return false;if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0)return false;
    return true;
}

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;


const int MOD = 1000000007;
const long double PI = 4*atan((long double)1);
const ll INF = 1e18;

int main()
{
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int ans=0;
    int n = (int)s.length();
    for(int i=0;i<n/2;++i){
        if(s[i]!=s[n-i-1])
            ans++;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256