akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[1000100];
void solve(){
	cin>>k>>n;
	int res=0;
	cin>>a[0];
	for(int i=1;i<n;++i){
		cin>>a[i];
		res=max(res,a[i]-a[i-1]);
	}
	res=max(res,k+a[0]-a[n-1]);
	cout<<k-res<<endl;
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define rep(i , N) for(int (i) = 0; (i) < (N); (i)++)


int main(){
    
    char X , Y; std::cin >> X >> Y;

    if(X == Y)std::cout << '=';
    else if(X > Y)std::cout << '>';
    else std::cout << '<';

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        while (scanner.hasNext()) {
            int[] a = new int[4];

            int hit = 0;
            int blow = 0;
            
            for (int i = 0; i < a.length; i++) {
                a[i] = scanner.nextInt();
            }
            
            for (int i = 0; i < a.length; i++) {
                int b = scanner.nextInt();
                for (int j = 0; j < a.length; j++) {
                    if (a[i] == b) {
                        hit++;
                        break;
                    } else if (a[j] == b) {
                        blow++;
                        break;
                    }
                }
            }
            System.out.println(hit + " " + blow);
        }
    }
}

Measured memory_bytes: 18108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

vector< pair<int,int> > leaf_to_root(const vector<int> &u,const vector<int> &v,const int root){
	// return <parent,child>
	int yet = 1000000000;
	vector<int> d(u.size()+1,yet);
	vector< pair<int,int> > res;
	queue<int> Q;
	Q.push(root);
	d[root] = 0;
	vector< vector<int> > G(u.size()+1);
	for(int i=0;i<u.size();i++){
		G[u[i]].push_back(v[i]);
		G[v[i]].push_back(u[i]);
	}
	while( Q.size() ){
		int now = Q.front();
		Q.pop();
		for(auto nex:G[now]){
			if(d[nex]!=yet)continue;
			d[nex] = d[now] + 1;
			Q.push(nex);
			res.push_back( make_pair(now,nex) );
		}
	}
	reverse(res.begin(), res.end());
	return res;
}


int main(){

	int N;
	ll ans=1,K,MOD=1000000007;
	cin >> N >> K;
	vector<int> x(N-1),y(N-1);
	FOR(i,0,N-1) cin >> x[i] >> y[i];
	FOR(i,0,N-1) x[i]--,y[i]--;

	auto route = leaf_to_root(x,y,0);
	ans = K;
	vector<int> cnt(N,0);
	reverse(route.begin(),route.end());
	for(auto a:route){
		int p = a.first;
		int c = a.second;
		ll count = K - cnt[p] - 1;
		cnt[p]++;cnt[c]++;
		( ans *= count ) %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	string s;
	cin >> s;
	for (size_t i = 0;i < s.size();i++) {
		if (s[i] == '?')
			s[i] = 'D';
	}
	cout << s << '\n';
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define MOD 1000000007
#define MAX 2100

ll fac[MAX], finv[MAX], inv[MAX];

void CombInit()
{
    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;
    }
}

ll Comb(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 argc, char **argv)
{
    int N, K;
    cin >> N >> K;

    CombInit();
    FOR(i, 1, K + 1) {
        // N-K+1 C i
        // K-1 C i-1
        cout << (Comb(N - K + 1, i) * Comb(K - 1, i - 1)) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define all(x) (x).begin(), (x).end()
    typedef long long ll;
    #define MOD 1000000007
    using namespace std;
    ll gcd(ll a, ll b) {
        if(a < b)
            return gcd(b, a);
        ll r = 1;
        while(r != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    ll modpow(ll a, ll n, ll mod = MOD) {
        ll res = 1;
        while(n > 0) {
            if(n & 1)
                res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }
    ll absll(ll a) {
        if ( a >= 0 ) return a;
        return -a;
    }
    ll sign(ll n) {
        if(n >= 0) {
            return 1;
        } else {
            return -1;
        }
    }
    int main() {
        int n;
        cin >> n;
        map<pair<ll, ll>, ll> cnt;
        for(int i = 0; i < n; i++) {
            ll a, b;
            cin >> a >> b;
            if(a == 0 && b == 0) {
                cnt[make_pair(0, 0)]++;
            } else if(a == 0 && b != 0) {
                cnt[make_pair(0, 1)]++;
            } else if(a != 0 && b == 0) {
                cnt[make_pair(1, 0)]++;
            } else {
                ll g = gcd(abs(a), abs(b));
                ll sig = sign(a) * sign(b);
                cnt[make_pair(sig * abs(a) / g, abs(b) / g)]++;
            }
        }
        ll ans = 1;
        for(auto e : cnt) {
            if(e.second == 0) {
                continue;
            }
            if(e.first == make_pair(0LL, 0LL)) {
                continue;
            }
            pair<ll,ll> ort;
            if(e.first == make_pair(0LL, 1LL)) {
                ort = make_pair(1, 0);
            } else if(e.first == make_pair(1LL, 0LL)) {
                ort = make_pair(0, 1);
            } else {
                ort = make_pair(-sign(e.first.first) * absll(e.first.second),
                                absll(e.first.first));
                ;
            }
            ans *= modpow(2, e.second) + modpow(2, cnt[ort]) - 1;
            ans %= MOD;
            cnt[ort] = 0;
            cnt[e.first] = 0;
        }
        cout << (cnt[make_pair(0, 0)] + ans - 1 + MOD) % MOD << endl;
    }

Measured memory_bytes: 28608
using System;
using System.Linq;
using System.Collections.Generic;

namespace abc085b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            for(int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            int ans = 0;
            ans = a.Distinct().Count();
            Console.WriteLine(ans);
        }
    }
}


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

const int MAX = 3;
int main() {
	char s[MAX];
	int sum = 0;
	cin >> s;
	for (int i = 0;i < MAX;i ++) {
		if (s[i] == '1') sum ++; // ビー玉を置くマス
	}
	cout << sum;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

要するに、s_i==1(1<=i<=3)ならビー玉を置くので、
ループで回して1の個数を数え上げれば良いよ
あ、char配列で読み込んだから、ちゃんとs[i]との比較は1じゃなく'1'にしてね！
*/

Measured memory_bytes: 764
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

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

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, m, x, y;

int main() {
    fast_io;

    cin >> n >> m >> x >> y;
    if (x > m / 2 || y > n / 2) return cout << -1 << endl, 0;

    for (ll i = 0; i < y; i++) {
        for (ll j = 0; j < m; j++) {
            if (j < x) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
    for (ll i = y; i < n; i++) {
        for (ll j = 0; j < m; j++) {
            if (j < x) cout << 0;
            else cout << 1;
        }
        cout << endl;
    }

    return 0;
}
/*

*/


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

   a=a-c;
   if(a>0)
   {
       cout<<a<<" "<<b<<endl;
   }
   else
   {
       ll p = a*(-1);
       a=0;
       b-=p;
       if(b<0)
       {
           b=0;
       }
       cout<<a<<" "<<b<<endl;
   }
}
				

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A')return 1;
  else if(ch=='C')return 2;
  else if(ch=='G')return 3;
  else if(ch=='T')return 4;
  else return 0;
  }

  long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
  }

  int h1(int key){return key % M;}
  int h2(int key){return 1+(key%(M-1));}

  int find(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
      h=(h1(key)+i*h2(key))%M;
      if(strcmp(H[h],str)==0)return 1;
      else if(strlen(H[h])==0)return 0;
    }
    return 0;
    }

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
    }
    return 0;
  }

  int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<M;i++)H[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%s %s",com,str);

      if(com[0]=='i'){
        insert(str);
      }else{
        if(find(str)){
          printf("yes\n");
        }else{
          printf("no\n");
        }
      }
    }
    return 0;
  }

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

int main(void){

	int n;
	cin >> n;

	int count = 0;

	for (int i = 0; i < n; i++){

		int m;
		cin >> m;
		if (m == 2) count++;
		else if(m % 2 == 1){
			bool flg = true;
			for (int j = 3; j <= (int)sqrt(m); j += 2){
				if (m % j == 0){
					flg = false;
					break;
				}
			}
			if (flg) count++;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	string a, b, c; cin >> a >> b >> c;
	int ans = 0;
	rep(i, n) {
		set<char> st;
		st.insert(a[i]);
		st.insert(b[i]);
		st.insert(c[i]);
		ans +=  st.size() - 1;
	}
	printf("%d\n", ans);
	return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    ll n, sum= 0;

    cin>> n;

    ll t= n;

    while (t> 0)
    {
        sum+= (t%10);
        t/=10;
    }



    cout << (n% sum== 0 ? "Yes\n" : "No\n");

    return 0;
}




Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N,K;
   cin >> N >> K;
   int V[N];
   for(int i=0;i<N; i++) cin >> V[i];
   int ans = 0;
   for(int i = 0 ; i <= min(K,N); i++){
      for(int j = 0 ; j+i <= min(K,N); j++){
         vector<int> v;
         for(int k=0;k<i; k++){
            v.push_back(V[k]);
         }
         for(int k=0;k<j; k++){
            v.push_back(V[N-1-k]);
         }
         sort(v.begin(),v.end());
         reverse(v.begin(),v.end());
         /*
         cout << i << ", " << j  << endl;
         for(int k=0;k<(int)v.size();k++) cout << v[i]<<" ";
         cout << endl;
         */
         int num = i+j;
         int rest = K-(i+j);
         int least_used=num-rest;
         int tmp = 0;
         int k=0;
         for(k=0; k< min(least_used,(int)v.size()); k++){
            tmp += v[k];
         }
         while(k<(int)v.size()&&v[k]>0) tmp += v[k++];
         ans=max(ans,tmp);
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
N = int(input())
x = list(map(int, input().split(' ')))
y = list(map(int, input().split(' ')))

count = x[0]
for i in range(N):
    count += y[i]

sums = count
for i in range(N - 1):
    count = count + x[i + 1] - y[i]
    if count > sums:
        sums = count

print(sums)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
#define endl "\n"
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int n; cin >> n;
	ll res=1;
	vll a;
	while(n--){
		ll x; cin >> x;
		a.pb(x);
	}
	if(find(all(a),0)!=a.end()){
		cout << 0 << endl;
		return 0;
	}
	for(ll x:a){
		if(res>((1000000000000000000)/x)){
			cout << -1 << endl;
			return 0;
		}
		res *= x;
	}
	cout << res << endl;
}

Measured memory_bytes: 4208
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

const int MAX = 100005;
vector<int> adj[MAX * 2];
bool visited[MAX * 2];
int countX;
int countY;

void dfs(int i) {
  if (visited[i]) return;
  visited[i] = true;

  if (i < MAX) {
    countX++;
  } else {
    countY++;
  }

  // cout << "adj[i]" <<adj[i] << endl;
  for (int j : adj[i]) {
    dfs(j);
  }
}

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

  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y + MAX);
    adj[y + MAX].push_back(x);
  }

  for (int i = 0; i < MAX * 2; i++) visited[i] = false;

  long long ans = 0;
  for (int i = 0; i < MAX * 2; i++) {
    countX = 0;
    countY = 0;
    if (!visited[i]) dfs(i);
    ans += (long long)countX * countY;
  }

  cout << (ans - N) << endl;

  return 0;
}

Measured memory_bytes: 10240
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        int x = in.ni(), y = in.ni();
        int min = 100, max = -100;
        for (int i = 0; i < n; i++) {
            max  = Math.max(max, in.ni());
        }
        for (int i = 0; i < m; i++) {
            min = Math.min(min, in.ni());
        }
        boolean flag = false;
        for (int i = x+1; i <= y; i++) {
            if(max<i&&min>=i){
                flag = true;
                break;
            }
        }
        out.println(flag?"No War":"War");

    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21204
import scala.io.StdIn._
object Main extends App {

  val wrong = Array.fill(2){readInt()}
    Array(1,2,3).find(i ⇒ !wrong.contains(i)).foreach(println)

  implicit class Scope[T](val value: T) extends AnyVal {
    def let[A](@inline func: T ⇒ A): A = func(value)
    def also(@inline func: T ⇒ Unit): T = {func(value);value}
    def minOption[A](implicit ev: T ⇒ Iterable[A], ord: Ordering[A]): Option[A] = if (value.isEmpty) None else Some(value.min)
  }
}

Measured memory_bytes: 25664
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0
using namespace std;
using ll = long long;

vector<vector<int> > dis;
vector<vector<bool> > vis;
int h, w;
vector<string> grid;


int bfs(int i, int j) {
	vis.clear();
	vis.resize(h, vector<bool>(w, false));
	dis.clear();
	dis.resize(h, vector<int>(w, 0));

	queue<pair<int,int> > q;
	q.push({i, j});
	dis[i][j] = 0;
	int x[4] = {-1, 1, 0, 0};
	int y[4] = {0, 0, -1, 1};
	vis[i][j] = true;
	int res = 0;
	while (!q.empty()) {
		auto node = q.front();
		q.pop();
		if (dis[node.first][node.second] > res)
			res = dis[node.first][node.second];
		rep (k, 0, 3) {
			int xx = node.first + x[k];
			int yy = node.second + y[k];
			if (xx >= 0 && xx < h && yy >=0 && yy<w && !vis[xx][yy] && grid[xx][yy]=='.') {
				vis[xx][yy] = true;
				dis[xx][yy] = dis[node.first][node.second] + 1;
				q.push({xx, yy});
			}
		}
	}
	return res;
}

void testcase() {
    cin >> h >> w;
    grid.resize(h);
    rep(i, 0, h-1)
    	cin >> grid[i];

    int res = 0;
    rep (i, 0, h-1) {
    	rep (j, 0, w-1) {
    		if (grid[i][j]=='.') {
    			res = max(res, bfs(i, j));
    		}
    	}
    }
    cout << res << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

int main(){
  int x,y;
  cin>>x>>y;
  vector<int> A={0,2,0,1,0,1,0,0,1,0,1,0};
  if(A.at(x-1)==A.at(y-1))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n;
V< V<int> > edges;
vll fac, invf;

ll powmod(ll m, ll p) {
    if (p == 0) return 1;
    ll tmp = powmod(m, p / 2);
    if (p & 1) return (tmp * tmp % MOD) * m % MOD;
    else return tmp * tmp % MOD;
}

V<int> subsz;
vll dp, ans;

int dfs_pre(int i, int p) {
    subsz[i] = 1;
    for (int e: edges[i]) {
        if (e == p) continue;
        subsz[i] += dfs_pre(e, i);
    }

    dp[i] = fac[subsz[i] - 1];
    for (int e: edges[i]) {
        if (e == p) continue;
        (dp[i] *= invf[subsz[e]] * dp[e] % MOD) %= MOD;
    }
    return subsz[i];
}

void dfs_reroot(int i, int p) {
    dp[i] = fac[n - 1];
    for (int e: edges[i]) {
        (dp[i] *= invf[subsz[e]] * dp[e] % MOD) %= MOD;
    }
    ans[i] = dp[i];

    for (int e: edges[i]) {
        if (e == p) continue;
        int origsub = subsz[i];
        ll origdp = dp[i];
        subsz[i] = n - subsz[e];
        (dp[i] *= fac[subsz[e]] * powmod(dp[e], MOD - 2) % MOD) %= MOD;
        (dp[i] *= fac[subsz[i] - 1] * invf[n - 1] % MOD) %= MOD;
        dfs_reroot(e, i);
        dp[i] = origdp, subsz[i] = origsub;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    edges.resize(n);
    for (int i = 1; i < n; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        edges[a].emplace_back(b), edges[b].emplace_back(a);
    }

    fac.resize(n + 1, 1), invf.resize(n + 1, 1);
    for (ll i = 2; i <= (ll)n; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        invf[i] = invf[i - 1] * powmod(i, MOD - 2) % MOD;
    }

    subsz.resize(n), dp.resize(n);
    dfs_pre(0, -1);
    ans.resize(n);
    dfs_reroot(0, -1);
    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 20980
#include<iostream>
using namespace std;
typedef pair<int,int> pii;
char grid[60][60];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int W,H;
int bw=3;
int dfs(int color,int w,int h){
   grid[h][w]=-1;
  int res=1;
  for(int i=0;i<4;i++){
    int nx,ny;
    nx=w+dx[i];ny=h+dy[i];
    if(0<=ny && ny<H &&
       0<=nx && nx < W){
      if(grid[ny][nx]=='.'){
	res += dfs(color,nx,ny);
      }else if(grid[ny][nx]=='W')bw=1 & bw;
      else if(grid[ny][nx]=='B')bw=2 & bw;
    }
  }
  return res;
}

void printGrid(){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << grid[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}  

int main(){
  while(cin>>W>>H){
    if(W==0)break;
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++){
	cin>>grid[i][j];
      }
    int white=0,black=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(grid[i][j]=='.'){
	  bw=3;
	  int tmp=dfs(0,j,i);
	  if(bw==1)white+=tmp;
	  else if(bw==2)black+=tmp;
	}
      }
    }
    cout << black << " " << white << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int inf=1000000000;
    int n,m,p;
    cin>>n>>m>>p;
    int a[m],b[m],c[m];
    vector<vector<int>>front_pas(n);
    vector<vector<int>>back_pas(n);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
        c[i]=p-c[i];
        back_pas[b[i]].push_back(a[i]);
        front_pas[a[i]].push_back(b[i]);
    }
    int check[n]={};
    int reach[n]={};
    queue<int>q;
    q.push(n-1);
    check[n-1]=1;
    while(q.size()){
        int x=q.front();
        q.pop();
        reach[x]++;
        for(int i=0;i<back_pas[x].size();i++){
            int y=back_pas[x][i];
            if(check[y]==0){
                check[y]=1;
                q.push(y);
            }
        }
    }
    for(int i=1;i<n;i++)check[i]=0;
    check[0]=1;
    q.push(0);
    while(q.size()){
        int x=q.front();
        q.pop();
        reach[x]++;
        for(int i=0;i<front_pas[x].size();i++){
            int y=front_pas[x][i];
            if(check[y]==0){
                check[y]=1;
                q.push(y);
            }
        }
    }
    vector<int>A;
    vector<int>B;
    vector<int>C;
    for(int i=0;i<m;i++){
        if(reach[a[i]]==2 && reach[b[i]]==2){
            A.push_back(a[i]);
            B.push_back(b[i]);
            C.push_back(c[i]);
        }
    }
    int M=A.size();
    int d[n];
    for(int i=0;i<n;i++)d[i]=inf;
    d[0]=0;
    for(int roop=0;roop<n;roop++){
        bool update=0;
        for(int i=0;i<M;i++){
            if(d[A[i]]<inf && d[B[i]]>d[A[i]]+C[i]){
                d[B[i]]=d[A[i]]+C[i];
                update=1;
            }
        }
        /*for(int i=0;i<n;i++)cout<<d[i]<<" ";
        cout<<endl;*/
        if(update==0)break;
        if(roop==n-1){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    cout<<max(0,-d[n-1])<<endl;
    //for(int i=0;i<n;i++)cout<<d[i]<<endl;
    return 0;
}


Measured memory_bytes: 4064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        String result = "Bob";

        if (a == 1 && b != 1) {
          result = "Alice";
        } else if (a > b && b != 1) {
          result = "Alice";
        } else if (a == b) {
          result = "Draw";
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int[] num = new int[3];
		num[0] = sc1.nextInt();
		num[1] = sc1.nextInt();
		num[2] = sc1.nextInt();
		int k = sc1.nextInt();
		Arrays.sort(num);

		for (int i = 0 ; i < k ; i++ ) {
			num[2] *= 2;
		}

		System.out.println(num[0] + num[1] + num[2]);

		sc1.close();

	}

}

Measured memory_bytes: 21844
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife
	
	int n, m, k, ans = 0;
	cin >> n >> m >> k;
	vector<string> arr(n);
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	for(int i = 0; i < (1<<n); i++) {
		for(int j = 0; j < (1<<m); j++) {
			int w = 0;
			for(int x = 0; x < n; x++)
				for(int z = 0; z < m; z++)
					if(((i>>x)&1)==0 && ((j>>z)&1)==0 && arr[x][z]=='#')
						w++;
			if(w==k)
				ans++;
		}
	}
	cout << ans << '\n';

	return 0;
}


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

using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;

ll binPow(ll x, ll y, ll md = mod){
    ll res = 1;
    x %= mod;
    while(y){
        if(y & 1){
            res = (res * x) % mod;
        }
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

void solve(){
   int a, b, h;
   cin >> a >> b >> h;
   cout << ((a + b) * h) / 2 << "\n";
 }

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{

	//最大公約数を求める関数（Gratest Common Divisor）
	//タイプはulongとする
	static ulong GCD(ulong a, ulong b)
	{
		//より大きい方をnとする
		ulong n = Math.Max(a, b);
		ulong m = Math.Min(a, b);

		//ループ処理（ユークリッドの互除法を利用）
		while(m != 0){
			ulong rem = n % m;
			n = m;
			m = rem;
		}

		return n;
	}

	//最小公倍数を求める関数（Least Common Multiple）
	/*
	GCD(a,b) * LCM(a,b) = ab、という性質を利用
	即ち、LCM(a,b) = ab / GCD(a,b)である。
	*/
	static ulong LCM(ulong a, ulong b){
		ulong lcm = 0;

		//より大きい方をnとする
		ulong n = Math.Max(a, b);
		ulong m = Math.Min(a, b);

		//最大公約数
		/*
		当然だが、gcdはnの約数なので、n/gcdは適当
		*/
		ulong gcd = GCD(n,m);
		lcm = n / gcd * m;

		return lcm;
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		int N = int.Parse(Console.ReadLine());
		ulong ans = 1;

		//毎回、最小公倍数を求める
		for(int i=0; i<N; i++){
			ulong T = ulong.Parse(Console.ReadLine());
			ans = LCM(ans,T);
		}

		Console.WriteLine(ans);

	}
}



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

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
//Fill(dp,0x3f3f3f3f)
#define DEBUG
#ifdef DEBUG
#endif
const int maxn = 1e5+10;


LL b_num[maxn], b_sum[maxn];
int a[maxn], b[maxn], c[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
    	scanf("%d", &a[i]);
    }
    for(int i = 1; i <= n; i++)
    {
    	scanf("%d", &b[i]);
    }
    for(int i = 1; i <= n; i++)
    {
    	scanf("%d", &c[i]);
    }
    sort(a+1, a+n+1);
    sort(b+1, b+n+1);
    sort(c+1, c+n+1);
    int pos = n;
    Fill(b_num, 0);
    Fill(b_sum, 0);
    for(int i = n; i >= 1; i--)
    {
    	while(pos>=1&&c[pos]>b[i])pos--;
    	b_num[i] = n-pos;
    }
    //cout << "b_num:\n";for(int i = 1; i <= n; i++)cout << b_num[i] << " ";cout << endl;
    for(int i = n; i >= 1; i--)
    {
    	b_sum[i] = b_num[i]+b_sum[i+1];
    }
    LL ans = 0;
    pos = 1;
    for(int i = 1; i <= n; i++)
    {
    	while(pos <= n&&b[pos] <= a[i])pos++;
    	if(pos > n)break;
    	ans += b_sum[pos];
    }
    printf("%lld\n", ans);






















    return 0;
}


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

using namespace std;


char c[8][8];

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

    int x = 0;
    int y = 0;

    while (c[y][x] == '#') {
        c[y][x] = '.';
        if (y == H - 1 && x == W - 1) {
            for (int i = 0; i < H; i++)
                for (int j = 0; j < W; j++) {
                    if (c[i][j] == '#') {
                        cout << "Impossible" << endl;
                        return 0;
                    }
                }
            cout << "Possible" << endl;
            return 0;
        }
        if (x + 1 < W && c[y][x + 1] == '#') {
            x++;
        } else if (y + 1 < H && c[y + 1][x] == '#') {
            y++;
        }
    }
    cout << "Impossible" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

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

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int ans = min({ p + q,p + r,r + q });
	cout << ans;
	return 0;
}










Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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


    [] {
        [] {
            [] {
                int A, N;

                cin >> N >> A;

                auto check = [&]{
                    return N % 500 <= A;
                };
                cout << (check() ? "Yes" : "No") << endl;

            }();

        }();
    }();

    return 0;
}


Measured memory_bytes: 888
import sys
n = int(input())
dic = {}
for i in range(n):
    a, b, *c = sys.stdin.readline().split()
    if a == '0':
        dic[b] = int(c[0])
    elif a == '1':
        print(dic[b] if b in dic else 0)
    else:
        if b in dic:
            del dic[b] 


Measured memory_bytes: 37512
code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
# cython: cdivision=True
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/lazysegtree>" namespace "atcoder":
    cdef cppclass lazy_segtree[S, OP, E, F, mapping, composition, id]:
        lazy_segtree(vector[S] v)
        void set(int p, S x)
        S get(int p)
        S prod(int l, int r)
        S all_prod()
        void apply(int p, F f)
        void apply(int l, int r, F f)
        int max_right[G](int l)
        int min_left[G](int r)
DEF mod = 998244353
cdef struct s_t:
    long v, s
ctypedef long f_t
cdef extern from *:
    ctypedef int op_t "myop"
    ctypedef int e_t "mye"
    ctypedef int m_t "mymapping"
    ctypedef int c_t "mycomposition"
    ctypedef int i_t "myid"
    ctypedef int g_t "myg"
    cdef s_t myop(s_t a, s_t b)
    cdef s_t mye()
    cdef s_t mymapping(f_t f, s_t x)
    cdef f_t mycomposition(f_t f, f_t g)
    cdef f_t myid()
    cdef bool myg(s_t k)
cdef s_t myop(s_t a, s_t b):
    return s_t((a.v * b.s + b.v) % mod, (a.s * b.s) % mod)
cdef s_t mye():
    return s_t(0, 1)
cdef f_t myid():
    return -1
cdef s_t mymapping(f_t f, s_t x):
    if f == myid(): return x
    return s_t((x.s - 1) * 443664157 * f % mod, x.s)
cdef f_t mycomposition(f_t f, f_t g):
    if f == myid(): return g
    return f
from libc.stdio cimport getchar, printf
cdef inline long read():
    cdef long b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: return c
        c = c * 10 + b
cdef main():
    cdef long n = read(), i, l, r, d
    cdef lazy_segtree[s_t, op_t, e_t, f_t, m_t, c_t, i_t] *seg = new lazy_segtree[s_t, op_t, e_t, f_t, m_t, c_t, i_t](vector[s_t](n, s_t(1, 10)))
    for i in range(read()):
        l, r, d = read(), read(), read()
        seg.apply(l - 1, r, d)
        printf('%ld\n', seg.all_prod().v)
main()
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 23416
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)998244353;
//}}}

int a[501][501];
int ans[250000][4];
int main(){
  int H, W;
  cin >> H >> W;
  rep(h, H){
    rep(w, W){
      cin >> a[h][w];
    }
  }
  int ansNum = 0;
  rep(h, H){
    if(h % 2 == 0){
      rep(w, W){
        if(h == H - 1 && w == W - 1) continue;
        if(a[h][w] % 2){
          ans[ansNum][0] = h;
          ans[ansNum][1] = w;
          if(w == W - 1){
            ans[ansNum][2] = h + 1;
            ans[ansNum][3] = w;
          }else{
            ans[ansNum][2] = h;
            ans[ansNum][3] = w + 1;
          }
          a[ans[ansNum][2]][ans[ansNum][3]]++;
          /*
          printf("[%d %d] ", h, w);
          printf(" %d %d %d %d\n", ans[ansNum][0] + 1, ans[ansNum][1] + 1, ans[ansNum][2] + 1, ans[ansNum][3] + 1);
          */
          ansNum++;
        }
      }
    }else{
      rrep(w, W){
        if(h == H - 1 && w == 0) continue;
        if(a[h][w] % 2){
          ans[ansNum][0] = h;
          ans[ansNum][1] = w;
          if(w == 0){
            ans[ansNum][2] = h + 1;
            ans[ansNum][3] = w;
          }else{
            ans[ansNum][2] = h;
            ans[ansNum][3] = w - 1;
          }
          a[ans[ansNum][2]][ans[ansNum][3]]++;
          /*
          printf("[%d %d] ", h, w);
          printf(" %d %d %d %d\n", ans[ansNum][0] + 1, ans[ansNum][1] + 1, ans[ansNum][2] + 1, ans[ansNum][3] + 1);
          */
          ansNum++;
        }
      }
    }
  }
  cout << ansNum << endl;
  rep(i, ansNum){
    printf("%d %d %d %d\n", ans[i][0] + 1, ans[i][1] + 1, ans[i][2] + 1, ans[i][3] + 1);
  }
  return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main()
{
int r,a1,a2,a3;
cin>>r;
a1=(double)(22/7)*r*r;
a2=(double)(22/7)*1*1;
a3=(int)a1/(int)a2;
cout<< a3;
return 0;
}


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

using namespace std;

typedef long long ll;
const ll modl = 1e9 + 7;


vector<vector<ll> > mul(vector<vector<ll> > mat, vector<vector<ll> > other) {
	ll n = mat.size();
	vector<vector<ll> > ans(n, vector<ll>(n, 0));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++) {
			for (ll k = 0; k < n; k++) {
				ans[i][j] = ((ans[i][j] + (mat[i][k] * other[k][j])) % modl);
			}
		}
	}
	return ans;
}

vector<vector<ll> > getMatrixPower(vector<vector<ll> > adj, ll k) {

	if (k == 1)
		return adj;

	vector<vector<ll> > res = getMatrixPower(adj, k / 2);
	if (k & 1) {
		return mul(adj, mul(res, res));
	}

	return mul(res, res);
}



int main() {

	ll n, k;
	cin >> n >> k;

	vector<vector<ll> > adj(n, vector<ll>(n));

	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < n; j++)
			cin >> adj[i][j];

	vector<vector<ll> > ans = getMatrixPower(adj, k);
	ll sum = 0ll;
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++) {
			sum = ((sum + ans[i][j]) % modl);
		}
	}

	cout << sum % modl << endl;

	return 0;
}

Measured memory_bytes: 4832
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 1<<17, mlg = 17, mod = 1e9 + 7;
ll n, dp[55][55*55], a;
void add(ll &a, ll b) {
	a += b;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> a;
	dp[0][0] = 1;
	for(int t, i = 0; i < n; i++) {
		cin >> t;
		for(int x = n; x--;)
			for(int j = 55*55-t; j--;)
				add(dp[x+1][j+t], dp[x][j]);
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++) add(ans, dp[i][i*a]);
	cout << ans;
	
}


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

const int MAX_N = 100000;

int main() {
	int N, t[MAX_N + 1], x[MAX_N + 1], y[MAX_N + 1];
	std::cin >> N;
	for(int i = 1; i <= N; ++i) {
		std::cin >> t[i] >> x[i] >> y[i];
	}
	t[0] = 0, x[0] = 0, y[0] = 0;

	for(int i = 1; i <= N; ++i) {
		int time = t[i] - t[i - 1];
		int dist = std::abs(x[i] - x[i - 1]) + std::abs(y[i] - y[i - 1]);
		if(time < dist || (dist - time) % 2 != 0) {
			std::cout << "No" << std::endl;
			return 0;
		} else continue;
	}

	std::cout << "Yes" << std::endl;
 }

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb emplace_back
#define pi pair<int,int>
using namespace std;
const int maxn = 1e2 + 4;

int n, w;
int W[maxn], V[maxn];
ll dp[maxn][100004];

int main(){
	cin>>n>>w;
	for (int i = 0; i < n; ++i){
		cin>>W[i]>>V[i];
	}
	dp[0][W[0]] = V[0];
	for (int i = 1; i < n; ++i){
		for (int j = 0; j <= w; ++j){
			if (W[i] <= j){
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-W[i]]+V[i]*1ll);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= w; ++i){
		ans = max(ans, dp[n-1][i]);
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 79360