akhauriyash/Code-Regression huggingface dataset:
import math
n = int(input())
xlist = list(map(float, input().split()))
ylist = list(map(float, input().split()))
#x, y = [list(map(int, input().split())) for _ in range(2)] 로 한방에 가능
print(sum(abs(xlist[i] - ylist[i]) for i in range(n)))
print(pow(sum(abs(xlist[i] - ylist[i]) ** 2 for i in range(n)),0.5))
print(pow(sum(abs(xlist[i] - ylist[i]) ** 3 for i in range(n)),1/3))
print(max(abs(xlist[i] - ylist[i])for i in range(n)))


Measured memory_bytes: 5724
computeMax :: Integral a => a -> a -> a
computeMax a b
    | x == y = 2 * y
    | otherwise = 2 * y - 1
    where
        x = min a b
        y = max a b


main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine :: IO [Int]
    print $ computeMax a b


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<string>> lunlun(10);
void dfs(string s, char c)
{
    s = s + c;
    lunlun[s.size() - 1].emplace_back(s);
    if (s.size() == 10)
        return;
    for (int i = -1; i < 2; i++)
    {
        if (s[s.size() - 1] == '0' && i == -1 || s[s.size() - 1] == '9' && i == 1)
            continue;
        else
        {
            int k = (int)(s[s.size() - 1]);
            dfs(s, char(k + i));
        }
    }
}
int main()
{
    ll n;
    cin >> n;
    for (int i = 1; i < 10; i++)
    {
        dfs("", char(i + 48));
    }
    ll cnt = 0;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < lunlun[i].size(); j++)
        {
            if (cnt == n - 1)
            {
                cout << lunlun[i][j] << endl;
                return 0;
            }
            cnt++;
        }
    }
}

Measured memory_bytes: 13940
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void)
{	
	int a, b;
	cin >> a >> b;
	print((a - 1)*(b - 1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct SegTree {
    int siz;
    vector<int> node;

    SegTree(vector<int> &v) : siz(1) {
        int N = v.size();
        while (siz < N)
            siz *= 2;
        node.resize(2 * siz - 1, INT_MAX);
        for (int i = 0; i < N; ++i)
            node[i + siz - 1] = v[i];
        for (int i = siz - 2; i >= 0; --i)
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }

    int lsearch(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        if (node[k] > x || r <= a || b <= l)
            return b;
        if (k >= siz - 1)
            return k - (siz - 1);
        int vl = lsearch(a, b, x, 2 * k + 1, l, (l + r) / 2);
        if (vl != b)
            return vl;
        return lsearch(a, b, x, 2 * k + 2, (l + r) / 2, r);
    }

    int rsearch(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        if (node[k] >= x || r <= a || b <= l)
            return a - 1;
        if (k >= siz - 1)
            return k - (siz - 1);
        int vr = rsearch(a, b, x, 2 * k + 2, (l + r) / 2, r);
        if (vr != a - 1)
            return vr;
        return rsearch(a, b, x, 2 * k + 1, l, (l + r) / 2);
    }
};

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

    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    SegTree segtree(a);
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int l = segtree.rsearch(0, i, a[i]);
        int r = segtree.lsearch(i + 1, N, a[i]);
        ans += (ll)a[i] * (i - l) * (r - i);
    }

    cout << ans << '\n';
    return 0;
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> t(N);
    int sum = 0;
    for (int i = 0; i < N; i++){
        cin >> t[i];
        sum += t[i];
    }
    int M;
    cin >> M;
    vector<int> p(M),x(M);
    for (int i = 0; i < M; i++){
        cin >> p[i] >> x[i];
        cout << sum + (x[i] - t[p[i]-1]) << endl;
    }





    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val a = sc.nextLong()
  val b = sc.nextLong()

  if (a > b) {
    println(0)
    return
  }
  if (n == 1L) {
    if (a != b) {
      println(0)
    } else {
      println(1)
    }
    return
  }

  val min = a + (n-2) * a + b
  val max = a + (n-2) * b + b
  println(max - min + 1L)

}


Measured memory_bytes: 36384
#include <stdio.h>

int main()
{
    int n, a[100];
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = n - 1; i >= 0; i--)
    {
        if (i != 0)
            printf("%d ", a[i]);
        else
            printf("%d", a[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2052
N,M,X = map(int,input().split())
A = list(map(int,input().split()))

cd = 0
cu = 0
for i in range(M):
    if A[i] > X:
        cu += 1
    elif A[i] < X:
        cd += 1
    else:
        ca += 1
        cd += 1
print(min(cu,cd))


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

map<pair<int,int> , int > m;
int a[5]; 
int b[5];
int ans;

int cmp(int q,int w)
{
	return q<w;
}

int main()
{
	cin>>a[0]>>a[1]>>a[2];
	while (1)
	{
		sort(a,a+3,cmp);
		if (a[0]%2 || a[1]%2 || a[2]%2) 
		{
			cout<<ans<<endl;
			return 0;
		}
		if (m.count(make_pair(a[0],a[1])) && m[make_pair(a[0],a[1])]==a[2]) return 0*puts("-1");
		m[make_pair(a[0],a[1])]=a[2];
		b[0]=(a[1]+a[2])/2;
		b[1]=(a[0]+a[2])/2;
		b[2]=(a[1]+a[0])/2;
		for (int i=0;i<3;i++) a[i]=b[i];
		ans++;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm> 
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include  <ctime>
#include <iomanip>
using namespace std;

#define ll                    long long int
#define ull                   unsigned long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar
#define gc                    getchar
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define mp                    make_pair
#define itoc(c)               ((char)(((int)'0')+c))
#define all(p)                p.begin(),p.end()
#define max(x,y)              ((x>y)?x:y)
#define min(x,y)              ((x<y)?x:y)
#define mid(s,e)              (s+(e-s)/2)
#define vi                    vector<int>
#define vvi                   vector<vector<int>>
const ll MOD = 1000000007;

ll modpow(ll a, ll b, ll mod) { ll res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; res%=mod; a = a * a; a%=mod; }return res; }
ll p(ll a, ll b) { ll res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a;a = a * a; }return res; }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /* code */
    ll n; cin >> n;
    ll ans = modpow(10,n,MOD);
    ans -= (2 * modpow(9,n,MOD))%MOD;
    ans += MOD; ans %= MOD;
    ans += modpow(8,n,MOD);
    ans %= MOD;
    cout << ans << "\n";
    /* end code */
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  vector<vector<pair<int, int> > > a(3, vector<pair<int, int> >(3, {0, 0}));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> a[i][j].first;
    }
  }
  int n; cin >> n;
  for(int i = 0; i < n; i++){
    int t; cin >> t;
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(t == a[j][k].first) a[j][k].second = 1;
      }
    }
  }
  for(int i = 0; i < 3; i++){
    int s = 0;
    for(int j = 0; j < 3; j++){
      if(a[i][j].second) s++;
    }
    if(s == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  for(int i = 0; i < 3; i++){
    int s = 0;
    for(int j = 0; j < 3; j++){
      if(a[j][i].second) s++;
    }
    if(s == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(a[0][0].second + a[1][1].second + a[2][2].second == 3){
    cout << "Yes" << endl;
    return 0;
  }
  if(a[0][2].second + a[1][1].second + a[2][0].second == 3){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  // end-----------------------------------------------
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

void solve()
{
	int n, m, x;
	cin >> n >> m >> x;
	
	int c[n];
	int grid[n][m];
	
	for(int i = 0; i<n; i++)
	{
		cin >> c[i];
		for(int j = 0; j<m; j++)
		{
			cin >> grid[i][j];
		}
	}
	
	int ans = INT_MAX;
	for(int mask = 0; mask<1<<n; mask++)
	{
		int cost = 0;
		vector<int> temp(m);
		for(int i = 0; i<n; i++)
		{
			if(mask&(1<<i))
			{
				cost += c[i];
				for(int j = 0; j<m; j++)
				{
					temp[j] += grid[i][j];
				}
			}
		}
		int flag = 1;
		for(int s :temp)
		{
			if(s < x)
			{
				flag = 0;
				break;
			}
		}
		if(flag) ans = min(ans, cost);
		
	}
	if(ans == INT_MAX) cout << -1 << "\n";
	else cout << ans << "\n";
}

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


Measured memory_bytes: 3584
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

ll sum(ll x){
  return (x*(x+1)/2)%mod;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,k,ans=0;cin>>n>>k;

  rep(i,k,n+2){
    ans+=1+(sum(n)-sum(n-i)+mod)-sum(i-1)+mod;
    ans%=mod;
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

double par(int t){
    double ret = 6;
    while(t--){
        ret*=6;
    }
    return 1 / ret;
}

int main(){
    int n, t, l, b;
    while(cin >> n >> t >> l >> b, n||t||l||b){
        double dp[102][101] = {0};
        dp[0][0] = 1;
        int m[102] = {0}; //1 == lose, 2 == back
        rep(i,l){
            int inp;
            cin >> inp;
            m[inp] = 1;
        }
        rep(i,b){
            int inp;
            cin >> inp;
            m[inp] = 2;
        }

        rep(j,t){
            rep(i,n + 1){
                range(k,1,7){
                    if(i == n){
                        dp[i][j + 1] += dp[i][j];
                        break;
                    }

                    int temp = k;
                    if(i + k > n) temp = 2 * (n - i) - k;
                    switch (m[i + temp]) {
                        case 0:
                            dp[i + temp][j + 1] += dp[i][j] / 6;
                            break;
                        case 1:
                            dp[i + temp][j + 2] += dp[i][j] / 6;
                            break;
                        case 2:
                            dp[0][j + 1] += dp[i][j] / 6;
                            break;
                    }
                }
            }
            /*
            double sum = 0;
            rep(k,n + 1){
                sum += dp[k][j + 1];
                debug(dp[k][j + 1]);
            }
            cout << endl;
            */
        }
        cout << fixed << setprecision(6) << dp[n][t] << endl;
    }
}

Measured memory_bytes: 3332
#include <iostream>

using namespace std;

int cnt(int n)
{
    int r = 0;
    while (n)
    {
        ++r;
        n /= 10;
    }
    return r;
}

int main()
{
    int n, c = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        if (cnt(i) & 1)
            ++c;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

def nC2(n):
    return n * (n - 1) // 2

n = int(input())
balls = [int(i) for i in input().split()]

c = Counter(balls)
total = 0
for k, v in c.items():
    total += nC2(v)

for i in range(n):
    ball = balls[i]
    num = c.get(ball)
    ans = total - nC2(num) + nC2(num - 1)
    print(ans)

Measured memory_bytes: 88268
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int count = int.Parse(Console.ReadLine());

        String[] aryX = Console.ReadLine().Split(' ');
        String[] aryY = Console.ReadLine().Split(' ');
        int[] aryZ = new int[count];

        for(int i = 0; i < count; i++ )
        {
            aryZ[i] = Math.Abs(int.Parse(aryX[i]) - int.Parse(aryY[i]));
        }

        //p1?¨????
        double sumP1 = 0;
        for( int i = 0; i < count; i++)
        {
            sumP1 += aryZ[i];
        }
        Console.WriteLine("{0:f6}",sumP1);

        //p2?¨????
        double sumP2 = 0;
        for (int i = 0; i < count; i++)
        {
            sumP2 += aryZ[i] * aryZ[i];
        }
        Console.WriteLine("{0:f6}", Math.Sqrt(sumP2));

        //p3?¨????
        double sumP3 = 0;
        for (int i = 0; i < count; i++)
        {
            sumP3 += aryZ[i] * aryZ[i] * aryZ[i];
        }
        Console.WriteLine("{0:f6}", Math.Pow(sumP3,1.0/3.0));

        //pmax?¨????
        double sumPmax = aryZ[0];
        for (int i = 0; i < count; i++)
        {
            if(sumPmax < aryZ[i])
            {
                sumPmax = aryZ[i];
            }
        }
        Console.WriteLine("{0:f6}", sumPmax);

    }
}

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

int main(){
  	int N;
  	cin>>N;
  	int count=0;
  	for(int i=0;i<N;i++){
      	if(count==3)
          	break;
    	int a,b;
      	cin>>a>>b;
      	if(a==b)
          	count++;
     	else{
          count=0;
        }
    }
  	if(count==3)
      	cout<<"Yes";
  	else
      	cout<<"No";
 	return 0; 
}

Measured memory_bytes: 3632
import sys, math
from functools import lru_cache
import heapq
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def solve(s, e, x, y):
    cnt = 0
    if s:
        x *= -1
        cnt += 1
    if e:
        y *= -1
        cnt += 1

    if y-x>=0:
        cnt += y-x
        return cnt
    else:
        return math.inf


def main():
    x, y = mi()
    ss = [True, True, False, False]
    es = [True, False, True, False]
    m = math.inf

    for i in range(4):
        m = min(m, solve(ss[i], es[i], x, y))

    print(m)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9520
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline
    n = int(input())
    l = list(map(int,input().split()))
    check = [[1]*n for i in range(n)]
    d = [[float("INF")]*n for i in range(n)]

    for i in range((n+1)//2):
        for j in range(i,n-i):
            d[i][j] = i
            d[-1-i][j] = i
        for j in range(i,n-i):
            d[j][i] = i
            d[j][-1-i] = i
    def solve(l):
        ans = 0
        for t in l:
            t -=1
            x = t//n
            y = t%n
            check[x][y] = 0
            ans += d[x][y]
            q = deque([])
            q.append((x,y,d[x][y]))
            while q:
                bx,by,z = q.popleft()

                if bx != 0:
                    if d[bx-1][by] > z:
                        d[bx-1][by] = z
                        q.append((bx-1,by,z+check[bx-1][by]))
                if bx != n-1:
                    if d[bx+1][by] > z:
                        d[bx+1][by] = z
                        q.append((bx+1,by,z+check[bx+1][by]))
                if by != 0:
                    if d[bx][by-1] > z:
                        d[bx][by-1] = z
                        q.append((bx,by-1,z+check[bx][by-1]))
                if by != n-1:
                    if d[bx][by+1] > z:
                        d[bx][by+1] = z
                        q.append((bx,by+1,z+check[bx][by+1]))  
        return ans

    
    print(solve(l))

if __name__ =="__main__":
    main()

Measured memory_bytes: 173480
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
kk = h.index(max(h))
for i in range(101):
    for j in range(101):
        H = h[kk] + abs(x[kk] - i) + abs(y[kk] - j)
        for k in range(n):
            if h[k] > 0:
                if H != abs(x[k]-i)+abs(y[k]-j)+h[k]:
                    H = -1
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    H = -1
        if H != -1:
            print(i, j, H)

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++){
        cin >> v[i];
    }
    int dp[100005]={0};
    for(int i=2;i<=n;i++){
        dp[i]= INT_MAX;
        for(int j=1;j<=2;j++){
            if(i-j>0)
            dp[i]= min(dp[i], dp[i-j]+abs(v[i]-v[i-j]));
        }
        //cout << i << " " << dp[i] << endl;
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
#define EPS (1E-10)
const int maxn=100000+10;
int n;

struct Point
{
    int x,y;
    Point() {}
    Point(int _x,int _y):x(_x),y(_y) {}
    Point operator -(Point p)
    {
        return Point(x-p.x,y-p.y);
    }
    bool operator <(Point p)
    {
        return x==p.x?y<p.y:x<p.x;
    }
    int cross(Point p)
    {
        return x*p.y-y*p.x;
    }
    int dot(Point p)
    {
        return x*p.x+y*p.y;
    }
    int norm()
    {
        return x*x+y*y;
    }

};
vector<Point> ps;

int ccw(Point p,Point p1,Point p2)
{
    #define COUNT_CLOCKWISE 1
    #define CLOCKWISE -1
    #define ONLINE_FRONT 2
    #define ONLINE_BACK -2
    #define ON_SEGMENT 0
    Point a=p1-p;
    Point b=p2-p;
    if(a.cross(b)<-EPS) return CLOCKWISE;
    if(fabs(a.cross(b)<EPS)) return CLOCKWISE;
    if(a.cross(b)>EPS) return COUNT_CLOCKWISE;
    if(a.dot(b)<-EPS) return ONLINE_BACK;
    if(a.norm()<b.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;

}
int is_contain(vector<Point> ps,Point p)
{
    Point a,b;
    int n=(int)ps.size();
    bool flag=false;
    for(int i=0;i<n;i++)
    {
        a=ps[i]-p;
        b=ps[(i+1)%n]-p;
        if(a.y>b.y) swap(a,b);
        if(a.y<=EPS&&b.y>EPS&&a.cross(b)>EPS) flag=!flag;
        if(abs(a.cross(b))<EPS&&a.dot(b)<EPS) return 1;
    }
    return flag?2:0;
}

int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int x,y;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        ps.push_back(Point(x,y));
    }
    int q;
    Point p;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d%d",&p.x,&p.y);
        printf("%d\n",is_contain(ps,p));
    }



    return 0;

}

Measured memory_bytes: 3188
N = int(input().strip())
scores = [int(input().strip()) for _ in range(N)]
ans = sum(scores)
if ans%10 != 0:
  print(ans)
  exit()
others = [s for s in scores if s%10 != 0]
if len(others) == 0:
  print(0)
else:
  print(ans-min(others))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <sstream>
// #include <cmath>
// #include <map>
// #include <set>
// #include <deque>
// #include <stack>
// #include <vector>
using namespace std;
#define debug freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
// #define PI acos(-1)
typedef long long ll;
const int mod=1e9+7;

int main()
{
	//debug;
	ios;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(max(a*c,a*d),max(b*c,b*d));
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include <numeric>
int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector<int> P(N);
    for(int i=0; i<N; i++){
        std::cin >> P[i];
    }
    sort(P.begin(), P.end());
    std::cout << std::accumulate(P.begin(), P.begin()+K, 0) << "\n";
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(){
    double w, h, x, y;
    double s;
    cin >> w >> h >> x >> y;
    s = (w * h) / 2;
    printf("%.9f ", s);
    if((w / 2 == x) && (h / 2 == y))
        cout << 1 << endl;
    else
        cout << 0 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Aising2018
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nq = ReadInts();
            int n = nq[0];
            int q = nq[1];
            int[] array = ReadInts();
            int[][] xs = new int[q][];
            for(int i = 0; i < q; i++)
            {
                xs[i] = new int[2] { ReadInt(), i };
            }
            Array.Sort(xs, (a, b) => b[0] - a[0]);
            var crossSums = new long[n];
            crossSums[0] = array[0];
            crossSums[1] = array[1];
            var allSums = new long[n];
            allSums[0] = array[0];
            allSums[1] = allSums[0] + array[1];
            for(int i = 2; i < n; i++)
            {
                crossSums[i] = crossSums[i - 2] + array[i];
                allSums[i] = allSums[i - 1] + array[i];
            }
            int boundary = n - 1;
            long[] res = new long[q];
            for (int i = 0; i < q; i++)
            {
                while (boundary >= 2)
                {
                    int next = boundary - 2;
                    int mid = (n - 1 + next) / 2;
                    if (xs[i][0] - array[next] <= array[mid] - xs[i][0])
                    {
                        boundary -= 2;
                    }
                    else
                    {
                        break;
                    }
                }
                //Console.WriteLine(boundary);
                int nowMid = (n - 1 + boundary) / 2;
                res[xs[i][1]] = allSums[n - 1] - allSums[nowMid - 1];
                if (boundary >=2) res[xs[i][1]] += crossSums[boundary - 2];
            }

            for(int i = 0; i < q; i++)
            {
                Console.WriteLine(res[i]);
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 33368
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>

using namespace std;

struct Trading {
    int cnt;
    bool check[2];
} trad[1001];

int main() {
    int c, mode = 0;
    string s;
    while (getline(cin, s)) {
        if (s == "") {
            mode++;
            continue;
        }
        sscanf(s.data(), "%d", &c);
        trad[c].cnt++;
        trad[c].check[mode] = true;
    }
    for (int i = 1; i < 1001; i++) {
        if (trad[i].check[0] && trad[i].check[1]) {
            cout << i << " " << trad[i].cnt << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	ans+=max(n-2,0ll)*max(m-2,0ll);
	if(n==1&&m==1){
		ans+=1;
	}
	else if(n==1){
		ans+=m-2;
	}
	else if(m==1){
		ans+=n-2;
	}
	cout<<ans;
	re 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n), f(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> f[i];

  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  // めぐる式にぶたん
  ll left = -1, right = 10000000000000;
  while (right - left > 1) {
    ll mid = (left + right) / 2;
    // チームの成績をmid以下にできるか？
    bool can = true;
    ll count = 0;
    for (int i = 0; i < n; i++)
      count += max(0ll, a[i] - mid / f[i]);  // それ以下にするのに必要な修行回数
    if (count <= k)
      right = mid;
    else
      left = mid;
  }

  cout << right << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,C;
  cin >> N >> C;
  int N_MAX=510;
  int C_MAX=40;
  int D[C_MAX][C_MAX]={0};
  for(int i=1;i<=C;i++){
    for(int j=1;j<=C;j++){
      cin >> D[i][j];
    }
  }
  int c[10][40]={0};
  int q;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      cin >> q;
      c[(i+j)%3][q]++;
    }
  }
  ll cnt=0;
  ll ans=INF;
  for(int i=1;i<=C;i++){
    for(int j=1;j<=C;j++){
      if(i==j)continue;
      for(int k=1;k<=C;k++){
        if(j==k||k==i)continue;
        cnt=0;
        for(int m=1;m<=C;m++){
          cnt+=D[m][i]*c[0][m];
          cnt+=D[m][j]*c[1][m];
          cnt+=D[m][k]*c[2][m];
        }
        ans=min(cnt,ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func calcScore(day int, score, c, last []int) (int, []int) {
	loss := make([]int, 26)
	for i := 0; i < 26; i++ {
		loss[i] = c[i] * (day - last[i])
	}

	ret := 0
	new := make([]int, 26)
	for j := 0; j < 26; j++ {
		new[j] = score[j] - loss[j]
		ret += new[j]
	}

	return ret, new
}

func calcAllScore(D int, days []int, c []int, s [][]int) int {
	last := make([]int, 26)
	score := make([]int, 26)

	ans := 0
	for i := 0; i < D; i++ {
		t := days[i]
		score[t] += s[i][t]
		last[t] = i + 1
		ret, nw := calcScore(i+1, score, c, last)
		score = nw
		ans = ret
		// out(score)
	}
	return ans
}

var tab [366][26]int
var sum [366][26]int
var exe [366]int
var D int
var c []int
var s [][]int

func calc(typ int) {
	score := 0
	last := 0
	for i := 1; i <= D; i++ {
		if tab[i][typ] == 1 {
			score += s[i][typ]
			last = i
		}
		score += c[typ] * (last - i)
		sum[i][typ] = score
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	D = getInt()
	c = getInts(26)
	s = make([][]int, D+1)
	for i := 0; i < D; i++ {
		s[i+1] = getInts(26)
	}

	for i := 1; i <= D; i++ {
		t := rand.Intn(26)
		tab[i][t] = 1
		exe[i] = t + 1
	}
	for i := 0; i < 26; i++ {
		calc(i)
	}

	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()
	for i := 1; i <= D; i++ {
		fmt.Fprintln(wr, exe[i])
	}
	// M := getInt()
	// for i := 0; i < M; i++ {
	// 	d, q := getInt(), getInt()-1
	// 	tab[d][q] = 1
	// 	if exe[d] != 0 {
	// 		tab[d][exe[d]-1] = 0
	// 	}
	// 	for i := 0; i < 26; i++ {
	// 		calc(i)
	// 	}
	// 	exe[d] = q + 1
	// 	tot := 0
	// 	for i := 0; i < 26; i++ {
	// 		tot += sum[D][i]
	// 	}
	// 	fmt.Fprintln(wr, tot)
	// }
}


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

/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

using namespace std;

typedef long long ll;

int n;

int a;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a;
        if((a & 1) && (i & 1))
            ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
template<typename tn> void read(tn &a){
    tn x=0,f=1;char c=' ';
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
    a=x*f;
}
int n,k,a,ans;
int main(){
	read(n);
	read(k);
	for(int i=1;i<=n;i++){
		read(a);
		if(a>=k) ans++;
	}
	printf("%d\n",ans);
	return 0;
} 

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int d, n;
    cin >> d >> n;
    int first = 1;
    rep(i,d) first *= 100;
    if(n == 100) n++;
    cout << first * n << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  rep(i, N) {
    string S;
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      return 0;
    }
  }
  
  cout << "Three" <<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll LNF = 1LL<<60;

ll v[110];
ll w[110];
ll dp[110][100010];

int main(){
    int a,b; cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

int inv(int x) {
  return power(x, mod - 2);
}

void precalc() {
}

const int maxn = 810;
int n, m;
int gox[4] = {1, 0, -1, 0}, goy[4] = {0, 1, 0, -1};
char s[maxn][maxn];

bool inside(int x, int y) {
  return 0 <= x && x < n && 0 <= y && y < m;
}

int curx, cury;
int k;

bool read() {
  if (scanf("%d%d%d", &n, &m, &k) < 3) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  return true;
}

int dist[maxn][maxn];

void solve() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'S') {
        eprintf("!\n");
        curx = i, cury = j;
      }
      dist[i][j] = inf;
    }
  }
  vector<pair<int, int> > q(1, mp(curx, cury));
  dist[curx][cury] = 0;
  int res = inf;
  for (int i = 0; i < sz(q); i++) {
    int curx = q[i].first;
    int cury = q[i].second;
    eprintf("%d %d\n", curx, cury);
    if (dist[curx][cury] > k) {
      break;
    }
    res = min(res, 1 + (min(min(curx, n - 1 - curx), min(cury, m - 1 - cury)) + k - 1) / k);
    for (int j = 0; j < 4; j++) {
      int nx = curx + gox[j];
      int ny = cury + goy[j];
      if (dist[nx][ny] < inf) {
        continue;
      }
      if (!inside(nx, ny)) {
        continue;
      }
      if (s[nx][ny] == '#') {
        continue;
      }
      dist[nx][ny] = dist[curx][cury] + 1;
      q.pb(mp(nx, ny));
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}



Measured memory_bytes: 13420
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,L;
  cin>>N>>L;
  vector<int> prime(N), abs_prime(N);
  int sum=0;
  for(int i=0;i<N;i++){
    prime[i]=L+i;
    abs_prime[i]=abs(L+i);
    sum+=prime[i];
  }
  int ans=*(min_element(abs_prime.begin(),abs_prime.end()));
  int tmp;
  for(int i=0;i<N;i++){
    if(abs_prime[i]==ans){
      tmp=i;
      break;
    }
  }
  
  cout<<sum-prime[tmp];
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
typedef struct{
	char name[100];
	int time;
} roll;

void enqueue(roll);
roll dequeue(void);

int head=0,tail=0;
roll Q[MAX];

	int main(void){
	int n,q,i,sum=0;
	roll p;

		scanf("%d%d",&n,&q);
		for(i=0;i<n;i++){
			scanf("%s%d",p.name,&p.time);
			enqueue(p);
		}
		while(1){
			if(head == tail) break;
			if(Q[head].time > q){
				p = dequeue();
				p.time -= q;
				enqueue(p);
				sum += q; 
			}
			else{
				p = dequeue();
				printf("%s %d\n",p.name,p.time+sum);
				sum += p.time;
			}
		}
return 0;
}

void enqueue(roll p){
Q[tail] = p;
if(tail+1 == MAX) tail = 0;
else tail++;
}

roll dequeue(){
	roll x;
	x = Q[head];

	if(head+1 == MAX) head = 0;
	else head++;
	return x;
}

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

using namespace std;

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

  string n;
  cin >> n;
  for (size_t i = 0; i < n.size(); ++i) {
    if (n[i] == '9') n[i] = '1';
    else if (n[i] == '1') n[i] = '9';
  }
  cout << n << "\n";
}


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

int main() 
{
    string S;
    cin >> S;
    
    int a = 0;
    for (char i = 'a'; i <= 'z'; i++) {
        if(S.find(i) > S.size()){
            cout << i << endl;
            return 0;
        }
        a++;
    }
    cout << "None" << endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <cstring>	// require memset 
//#include <fstream>

using namespace std;
const int MAX_N = 100;
const int MAX_M = 100;
int ice[MAX_N][MAX_M];
int d[MAX_N][MAX_M];

int max_depth = 0;

void dfs (int row, int col, int depth  )
{
	d[row][col] = 0;

	if (d[row - 1][col] == 1 ){
		dfs (row - 1, col, depth + 1 );
	} // end if
	if (d[row][col + 1] == 1 ){
		dfs (row, col + 1, depth + 1 );
 	} // end if
	if (d[row + 1][col] == 1 ){
		dfs (row + 1, col, depth + 1 );
	} // end if
	if (d[row][col - 1] == 1 ){
		dfs (row, col - 1, depth + 1 );
	} // end if

	d[row][col] = 1;

	if (d[row - 1][col] == 0 && d[row][col + 1] == 0
	&&  d[row + 1][col] == 0 && d[row][col - 1] == 0 ){
		if (depth + 1 > max_depth ){
			max_depth = depth + 1;
		} // end if
	} // end if
}

int calc (int row, int col, int size, int len )
{
	int i, j;

	max_depth = 0;

	for (i = 0; i <= size; ++i){
		for (j = 0; j <= len; ++j){
			d[i][j] = ice[i][j];
		} // end for
	} // end for

	dfs (row, col, 0 );
	
	int res = max_depth;

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.crossingice2", "r", stdin );
	int m, n;

	while (cin >> m >> n  && m && n ){
		memset (ice, 0, sizeof (ice ) );
		int i,j;

		for (i = 1; i <= n; ++i){
			for (j = 1; j <= m; ++j){
				cin >> ice[i][j];
			} // end for
		} // end for
	
		int res = 0;	
		for (i = 1; i <= n; ++i){
			for (j = 1; j <= m; ++j){
				if (ice[i][j] == 1 ){
					int sum = calc (i, j, n, m );
					res = max (res, sum );
				} // end if
			} // end for
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 940
import java.util.*;
import java.text.*;


public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int answer = a - b * 2;
		if(answer <= 0)
			System.out.println(0);
		else
			System.out.println(answer);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<int>> mp(h, vector<int>(w));
    rep(i,h){
        rep(j,w){
            cin >> mp[i][j];
        }
    }
    int cnt = 0;
    vector<string> str;
    rep(i,h){
        rep(j,w-1){
            if(mp[i][j]%2!=0){
                mp[i][j + 1]++;
                mp[i][j]--;
                cnt++;
                string s;
                s += to_string(i + 1);
                s += " ";
                s += to_string(j + 1);
                s += " ";
                s += to_string(i+1);
                s += " ";
                s += to_string(j+2);
                str.push_back(s);
            }
        }
    }
    rep(i,h-1){
        if(mp[i][w-1]%2!=0){
            mp[i + 1][w-1]++;
            mp[i][w-1]--;
            cnt++;
            string s;
            s += to_string(i+1);
            s += " ";
            s += to_string(w);
            s += " ";
            s += to_string(i+2);
            s += " ";
            s += to_string(w);
            str.push_back(s);
        }
    }
    cout << cnt << endl;
    rep(i,cnt){
        cout << str[i] << endl;
    }
}


Measured memory_bytes: 11892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
const int MOD = 1e9+7;
const int INF = 1e9;
const int MAXN = 1050000;

ll N,T,a,b,c,d,e,f;
vpi V;
ll X,Y;

int main(){
  cin>>X>>Y>>a>>b>>c;
  for (int i=0;i<a;++i){
    cin>>d;
    V.pb(d,0);
  }
  for (int i=0;i<b;++i){
    cin>>d;
    V.pb(d,1);
  }
  for (int i=0;i<c;++i){
    cin>>d;
    V.pb(d,2);
  }
  sort(ALL(V));
  a=b=c=0;
  while (SZ(V)){
    pi t = V.back();V.pop_back();
    if (a+b+c==X+Y)continue;
    if (t.s==0&&a==X)continue;
    if (t.s==1&&b==Y)continue;
    T += t.f;
    if (t.s==0){
      ++a;
    }else if (t.s==1){
      ++b;
    }else{
      ++c;
    }
  }
  cout<<T;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,w,b,tag,cnt;vector<int> v[100005],path;
void dfs(int x,int fa){
    path.pb(x);
    if(x==n){
        int len=path.size();
        tag=path[(len+1)/2];
    }
    rap(i,0,v[x].size())
    if(fa!=v[x][i]) dfs(v[x][i],x);
    path.pop_back();
}
void dfs2(int x,int fa){
    cnt++;
    rap(i,0,v[x].size())
    if(fa!=v[x][i]&&v[x][i]!=tag) dfs2(v[x][i],x);
}
int main()
{
    scanf("%d",&n);
    rap(i,1,n){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        v[t1].pb(t2);v[t2].pb(t1);
    }
    dfs(1,0);
    dfs2(1,0);
    puts(cnt>n-cnt?"Fennec":"Snuke");
    return 0;
}

Measured memory_bytes: 10872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define int ll
int div(int n){
	int c = 1 , temp = 7;
	while(temp%n != 0){
		temp = (temp%n)*10+7;
		c++;
	}
	return c;
}


void test_case(){
	int n; cin >> n;
	if(n%2==0 || n%5==0){
		cout<<"-1";
		return;
	}
	cout<<div(n);
}
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}
// 7/9(10^n - 1)
// x%k==0
//x*10+7


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String input = "";
		String[] data = new String[3];
		Double a = 0.0;
		Double b = 0.0;
		int C = 0;
		Double another_line = 0.0; // 三角形のもう1辺
		Double S = 0.0; // 三角形の面積
		Double L = 0.0; // 三角形の3辺の合計
		Double h = 0.0; // aを底辺としたときの高さ

		input = sc.nextLine();
		data = input.split(" ");
		a = Double.parseDouble(data[0]);
		b = Double.parseDouble(data[1]);
		C = Integer.parseInt(data[2]);

		// もう1辺を求める
		another_line = Math.sqrt(a * a + b * b - 2 * a * b
				* Math.cos(Math.toRadians(C))); // 余弦定理c^2=a^2+b^2-ab*cosCより

		// 面積を求める
		S = a * b * Math.sin(Math.toRadians(C)) * 0.5; // S=1/2*(ab)*sinCより

		// 3辺の合計を求める
		L = a + b + another_line;

		h = 2 * S / a;
		System.out.printf("%.5f", S);
		System.out.println();
		System.out.printf("%.5f", L);
		System.out.println();
		System.out.printf("%.5f", h);
	}

}



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

int fld[100][100];//[横][縦]
int Dx[4]={0,-1,0,1};
int Dy[4]={1,0,-1,0};

bool ans[1000];
int counter=0;

bool flag=true;

void dfs(int x,int y,int w,int h,int c){//スタート地点と色を与える
	fld[x][y]=-1;
	for(int i=0;i<4;i++){
		int nx=x+Dx[i],ny=y+Dy[i];//範囲内にある必要あり
		if(nx>=0 && nx<w && ny>=0 && ny<h){
		if(fld[nx][ny]==c)//同色についてのみ継続
			dfs(nx,ny,w,h,c);
		}
	}
}//色の塗り替え
	

void solve(){
	int w,h,xs,ys,xg,yg,n;
	cin >> w>>h;
	
	if(w==0) {flag=false;counter--; return;}
	
	cin >>xs>>ys>>xg>>yg>>n;//start,goal座標は-1する
	xs--;ys--;xg--;yg--;
	
	for(int i=0;i<w;i++){//fieldの初期化0~w-1
		for(int j=0;j<h;j++){//0~h-1
			fld[i][j]=0;//0は何も無い
		}
	}
	
	for(int i=0;i<n;i++){
		int color,drc,x,y;
		cin >>color>>drc>>x>>y;
		x--;y--;
		if(drc==0){
			for(int dx=0;dx<4;dx++){
				for(int dy=0;dy<2;dy++){
					fld[x+dx][y+dy]=color;
				}
			}
		}
		if(drc==1){
			for(int dy=0;dy<4;dy++){
				for(int dx=0;dx<2;dx++){
					fld[x+dx][y+dy]=color;
				}
			}
		}
	}//fieldの色塗り
	
	if(fld[xs][ys]!=fld[xg][yg]) {
		ans[counter]=false;
		return;
	}
	if(fld[xs][ys]==0){
		ans[counter]=false;
		return;
	}
	
	dfs(xs,ys,w,h,fld[xs][ys]);//塗り替え
	
	if(fld[xg][yg]==-1) ans[counter]=true;
	else ans[counter]=false;
	
	return;
}

int main(){
	while(flag){
		solve();
		counter++;
	}
	for(int i=0;i<counter;i++){
		if(ans[i]) cout << "OK"<<endl;
		else cout << "NG" << endl;
	}
	
}

Measured memory_bytes: 1196