akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;

pair<int, int> p[200009];
int rc[29][29];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		long long a = 0;
		bool f = false;
		int c = 0;
		for (int i = 0; i < s.length(); i++) {
			if (f) c++;
			if (s[i] != '.')
				a = a * 10 + 1LL * (s[i] - '0');
			else
				f = true;
		}
		for (int i = 0; i < 9 - c; i++)
			a *= 10;
		while (a % 2 == 0) {
			a /= 2; p[i].first++;
		}
		while (a % 5 == 0) {
			a /= 5; p[i].second++;
		}
		rc[min(p[i].first, 18)][min(p[i].second, 18)]++;
	}
	long long ans = 0;
	for (int i = 0; i <= 18; i++)
		for (int j = 0; j <= 18; j++)
			for (int ti = 0; ti <= 18; ti++)
				for (int tj = 0; tj <= 18; tj++) {
					if (i == ti && j == tj) continue;
					if (i + ti >= 18 && j + tj >= 18)
						ans += 1LL * rc[i][j] * rc[ti][tj];
				}
	ans /= 2;
	for (int i = 9; i <= 18; i++)
		for (int j = 9; j <= 18; j++)
			ans += 1LL * rc[i][j] * (rc[i][j] - 1) / 2;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5176
#include <iostream>

using namespace std;

int main()
{
    int n, a, pv_a, cnt=1, ans=0;
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>a;
        if (i==0) pv_a=a;
        else
        {
            if (a!=pv_a)
            {
                pv_a=a;
                ans+=cnt/2;
                cnt=1;
            }
            else cnt++;
        }
    }
    ans+=cnt/2;
    cout<<ans<<'\n';
    return 0;
}


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

namespace ConsoleApp15
{
    class Class37
    {
        static void Main()
        {
            var hn = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long sum = Console.ReadLine().Split().Select(long.Parse).Sum();
            Console.WriteLine(hn[0] > sum ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 18272
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

map<int, int> m;
int a[N];

signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n, k, ans = 0;;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i], a[i] += a[i-1];
	int l = 0;
	for(int i = 1; i <= n; i++){
		m[(a[i-1]-(i-1)+k)%k]++;
		while(l <= i-k){
			m[(a[l]-l+k) % k]--;
			l++;
		}
		ans += m[(a[i]-i+k) % k];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 14336
from itertools import accumulate

h, w = map(int, input().split())
field = [input() for _ in range(h)]

l = max(h, w)
precalc_rd = []
precalc_ld = []
for ij in range(h + w - 1):
    coins = [0] * (l + 1)
    min_i = max(0, ij - w + 1)
    max_i = ij - max(0, ij - h + 1)
    offset = (min_i - (ij - min_i) + w - 1) // 2 + 1
    for d in range(max_i - min_i + 1):
        i = min_i + d
        j = ij - i
        if field[i][j] == '#':
            coins[offset + d] = 1
    precalc_ld.append(list(accumulate(coins)))

for ij in range(-w + 1, h):
    coins = [0] * (l + 1)
    min_i = max(0, ij)
    max_i = ij + min(w - 1, h - ij - 1)
    offset = (min_i + (min_i - ij)) // 2 + 1
    for d in range(max_i - min_i + 1):
        i = min_i + d
        j = i - ij
        if field[i][j] == '#':
            coins[offset + d] = 1
    precalc_rd.append(list(accumulate(coins)))

ans = 0

for ij in range(h + w - 1):
    min_i = max(0, ij - w + 1)
    max_i = ij - max(0, ij - h + 1)
    offset = (min_i - (ij - min_i) + w - 1) // 2 + 1
    for sd in range(max_i - min_i + 1):
        si = min_i + sd
        sj = ij - si
        if field[si][sj] == '.':
            continue
        for td in range(sd + 1, max_i - min_i + 1):
            ti = min_i + td
            tj = ij - ti
            if field[ti][tj] == '.':
                continue
            dij = (td - sd) * 2
            if ij - dij >= 0:
                ans += precalc_ld[ij - dij][offset + td - 1] - precalc_ld[ij - dij][offset + sd - 1]
            if ij + dij <= h + w - 2:
                ans += precalc_ld[ij + dij][offset + td] - precalc_ld[ij + dij][offset + sd]

for ij in range(-w + 1, h):
    min_i = max(0, ij)
    max_i = ij + min(w - 1, h - ij - 1)
    offset = (min_i + (min_i - ij)) // 2 + 1
    for sd in range(max_i - min_i + 1):
        si = min_i + sd
        sj = si - ij
        if field[si][sj] == '.':
            continue
        for td in range(sd + 1, max_i - min_i + 1):
            ti = min_i + td
            tj = ti - ij
            if field[ti][tj] == '.':
                continue
            dij = (td - sd) * 2
            if ij - dij + w - 1 >= 0:
                ans += precalc_rd[ij - dij + w - 1][offset + td] - precalc_rd[ij - dij + w - 1][offset + sd]
            if ij + dij + w - 1 <= h + w - 2:
                ans += precalc_rd[ij + dij + w - 1][offset + td - 1] - precalc_rd[ij + dij + w - 1][offset + sd - 1]

print(ans)


Measured memory_bytes: 78532
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */

char s[11];

int main(void)
{
    int a;

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

    if(a>=3200)
    {
        printf("%s\n",s);
    }else
    {
        printf("red\n");
    }
    
    return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て

int		main(void)
{
	int N, X;
	cin >> N >> X;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	sort(all(A));
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		X -= A[i];
		if (X < 0)
			break;
		cnt++;
	}
	if (X > 0)
		cout << cnt - 1 << endl;
	else
		cout << cnt << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    char a[101],b[101];
    int n,cnt=0;
    scanf("%d%s%s",&n,a,b);
    for(int i=0;i<n*2;i++){
        if(i%2==0) printf("%c",a[cnt]);
        else {printf("%c",b[cnt]); cnt++;}
    }
}


Measured memory_bytes: 128
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())
    n=n%10
    if n==3:
        print("bon")
    elif n==0 or n== 1 or n== 6 or n==8:
        print("pon")
    else:
        print("hon")


if __name__ == '__main__':
    main()

Measured memory_bytes: 78252
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0

for i in range(n):
    ans += min(b[i],a[i]+a[i+1])
    a[i+1] = max(0,a[i+1] - max(0,(b[i]-a[i])))
print(ans)

Measured memory_bytes: 19116
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

uint N[9];
void input() {
    foreach (i; 0 .. 9) {
        scanf("%0x", &N[i]);
    }
}

bool biteq(uint x, uint a, uint b) {
    return ((a & (1 << x)) == (b & (1 << x)));
}

void solve() {
    uint x = 0;
    for (uint i = 0; i < 32; i++) {
        uint y = x;
        //writefln("%d: %0x", i, y);
        uint s = 0;
        foreach (j; 0 .. 8) {
            s += (N[j] ^ y);
        }
        if (s == (N[8] ^ y)) {
            writefln("%0x", y);
            return;
        }
        if (biteq(i, s, N[8] ^ y)) {
            x = y;
            continue;
        }
        s = 0;
        y = x | (1 << i);
        foreach (j; 0 .. 8) {
            s += (N[j] ^ y);
        }
        if (s == (N[8] ^ y)) {
            writefln("%0x", y);
            return;
        }
        if (biteq(i, s, N[8] ^ y)) {
            x = y;
            continue;
        }
        writefln("%0x", x);
    }
}
 
void main() {
    int T; scanf("%d\n", &T);
    foreach (t; 1 .. T + 1) {
        input;
        solve;
    }
}

Measured memory_bytes: 1068
s = input()
t = input()
ls, lt = map(len, [s, t])
for i in range(lt-1, ls)[::-1]:
    if ls < lt:
        break
    flag = 0
    for j in range(lt):
        if s[i-j] == "?":
            continue
        elif s[i-j] != t[lt-1-j]:
            flag = 1
            break
    if flag == 0:
        s = s.replace("?", "a")
        print(s[:i-lt+1]+t+s[i+1:])
        exit()
print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// ll N, M, Q;
// vll a, b, c, d;
// ll ans;
// void dfs(vll A) {
//   if ((ll)A.size() == N + 1) {
//     ll now = 0;
//     rep(i, Q) {
//       if (A[b[i]] - A[a[i]] == c[i]) {
//         now += d[i];
//       }
//       ans = max(ans, now);
//     }
//     return;
//   }

//   A.pb(A.back());
//   while (A.back() <= M) {
//     dfs(A);
//     A.back()++;
//   }
// }

signed main() {
  ll N, M, Q;
  ll ans = 0;
  cin >> N >> M >> Q;
  vll a(Q), b(Q), c(Q), d(Q);
  // a = b = c = d = vll(Q);
  rep(i, Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  // dfs(vll(1, 1));
  // COUT(ans);

  queue<vll> q;
  q.push(vll(0));
  while (!q.empty()) {
    vll v = q.front();
    q.pop();

    if ((ll)v.size() == N) {
      ll now = 0;
      rep(i, Q) {
        if (v[b[i] - 1] - v[a[i] - 1] == c[i]) {
          now += d[i];
        }
      }
      ans = max(ans, now);

    } else {
      if (v.size() == 0) {
        v.pb(1);
      } else {
        ll b = v.back();
        v.pb(b);
      }

      while (v.back() <= M) {
        q.push(v);
        v.back()++;
      }
    }
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 14640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cassert>
#include<deque>
 
using namespace std;
 
#define sz(x) (int)(x.size())
#define fr(i, a, b) for(int i=a;i<b;++i)
#define fdr(i, a, b) for(int i=b-1;i>=a;--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
/////////////////

int gcd(int a, int b){
	if(!a) return b;
	return gcd(b%a, a);
}


string YES = "POSSIBLE";
string NO = "IMPOSSIBLE";

void solve(){
	int n, k, x;
	vector<int> a;
	x = 0;
	cin >> n >> k;
	fr(i, 0, n){
		int v;
		cin >> v;
		x = gcd(x, v);
		a.pb(v);
	}
	
	bool ok = false;
	fr(i, 0, n){
		if(a[i] >= k && (a[i] - k) % x == 0) ok = true;
	}

	if(ok) cout << YES;
	else cout << NO;
	cout << endl;
}
 
int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
	solve();
 
 
	return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); //��
		int data[] = new int[N]; //�l�ۑ��p
		int cnt=0; //������s������
		
		for(int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		}
		while(checkNum(data)) {
			cnt++;
			for(int i=0;i<data.length;i++) {
				data[i] = data[i]/2;
			}
		}
		System.out.println(cnt);
	}
	static boolean checkNum(int n[]) {
		for(int i=0;i<n.length;i++) {
			if(n[i]%2 != 0)return false;
		}
		return true;
	} 
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define pb push_back
#define mp make_pair

void solve()
{
	char c;
	cin >> c;
	if ((int)c >= 65 && (int)c <= 91)
	{
		cout << "A\n";
	}
	else
		cout << "a\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin>>t;
	t = 1;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
a, b, c, x = [int(input()) for i in range(4)]

can_count = 0

for i in range(a+1):
	coins_price_500 = i * 500
	for j in range(b+1):
		coins_price_100 = j * 100
		for k in range(c+1):
			coins_price_50 = k * 50
			if x == coins_price_500 + coins_price_100 + coins_price_50:
				can_count += 1

print(can_count)

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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;
    cin >> n;
    long double money = 0;
    for (int z=0;z<n;z++){
    	long double a;string b;
    	cin >> a >> b;
    	if (b == "JPY") money += a;
    	else money += a*380000.0;
    }
    cout << setprecision(9) << fixed << money << endl;
    cin >> n;
}

Measured memory_bytes: 256
import string
import sys

F = sys.stdin

mydict = {}
alp = list(string.ascii_lowercase)

for i in alp:
        mydict[i] = 0

for line in F:
    line = line.rstrip()
    line = line.lower()
        
    
    for j in line:
        if j in alp:
            mydict[j] += 1
        
for key, value in mydict.items():
    print("{0} : {1}".format(key, value))


Measured memory_bytes: 6676
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void ColorfulSlimes2() {
	int N;
	cin >> N;
	int c = 0;
	int bef;
	cin >> bef;
	int n;
	for (size_t i = 1; i < N; i++)
	{
		cin >> n;
		if (bef == n) {
			c++;
			bef = -1;
		}
		else {
			bef = n;
		}
	}
	cout << c << "\n";
}
int main() {
	ColorfulSlimes2();
	return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
t = list(map(int, input().split()))

count = 0
oyu_time = 0
for i in range(N):
  if oyu_time >= t[i]:
    count += T - (oyu_time - t[i])
  else:
    count += T
  oyu_time = t[i] + T
print(count)

Measured memory_bytes: 85456
#include <iostream>

using namespace std;

int main(void)
{
	int join_times, out_rate;
	cin >> join_times >> out_rate;
	if (join_times < 10) cout << out_rate + (100 * (10 - join_times)) << endl;
	else cout << out_rate << endl;
	return (0);
}

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

int main(){
  int s;
  cin >> s;
  
  vector<int> cnt(1000000);
  int ans;
  cnt.at(s)++;
  for(int i = 2; i < 10000000; ++i){
    if(s % 2) s = 3 * s + 1;
    else s /= 2;
    if(cnt.at(s)){
      ans = i;
      break;
    }
    cnt.at(s)++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int n;
int ans[200010];
struct nu{
    int x,idx;
    bool operator < (const nu & other) const {
        return (x==other.x)?(idx<other.idx):(x<other.x);
    }
} a[200010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].x;
        a[i].idx = i;
    }
    sort(a+1,a+n+1);
    for(int i=(n/2)+1;i<=n;i++) ans[a[i].idx] = a[n/2].x;
    for(int i=(n/2);i>=1;i--) ans[a[i].idx] = a[n/2+1].x;
    for(int i=1;i<=n;i++) cout<<ans[i]<<'\n';

    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

string s,t;
map<string,int>M;
int ans=0;

void s_f(string res,int pos){
	if(pos==s.size()){
		M[res]=res.size();
		return;
	}
	else{
		s_f(res,pos+1);
		res+=s[pos];
		s_f(res,pos+1);
		return;
	}
}

void t_f(string res,int pos){
	if(pos==t.size()){
		ans=max(ans,M[res]);
		return;
	}
	else{
		t_f(res,pos+1);
		res+=t[pos];
		t_f(res,pos+1);
		return;
	}
}

int main(){
	string S;
	cin>>S;
	s="";
	t="";
	for(int i=0,j=0;i<S.size();i++){
		if(S[i]=='i')j++;
		else if(S[i]!='w'){
			if(j)t+=S[i];
			else s+=S[i];
		}
	}
	reverse(t.begin(),t.end());
	for(int i=0;i<t.size();i++){
		if(t[i]=='(')t[i]=')';
		else if(t[i]==')')t[i]='(';
		else if(t[i]=='{')t[i]='}';
		else if(t[i]=='}')t[i]='{';
		else if(t[i]=='[')t[i]=']';
		else if(t[i]==']')t[i]='[';
	}
	
	s_f("",0);
	t_f("",0);
	
	
	cout<<ans*2+3<<endl;
	
	
	return 0;
}


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

int n,a[200005];

inline bool check(const int &k){
    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;
    if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;
    for(int i=1;i<n-1;i++){
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;
        if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;
    }
    return a[1]<=k;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<n<<1;i++)scanf("%d",a+i);
    int l=1,r=(n<<1)-1;
    while(l<r){
        int mid=l+r>>1;
        if(check(mid))r=mid;
        else l=mid+1;
    }
    printf("%d",l);
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> a(H, vector<int>(W));
  REP(i, H) REP(j, W) cin >> a[i][j];
  vector<tuple<int, int, int, int>> ans;
  REP(i, H) REP(j, W-1){
    if(a[i][j]%2){
      a[i][j]--;
      a[i][j+1]++;
      ans.emplace_back(i+1, j+1, i+1, j+2);
    }
  } 
  REP(i, H-1){
    if(a[i][W-1]%2){
      a[i][W-1]--;
      a[i+1][W-1]++;
      ans.emplace_back(i+1, W, i+2, W);
    }
  }
  int n = ans.size();
  cout << n << endl;
  REP(i, n){
    int o, p, q, r;
    tie(o, p, q, r) = ans[i];
    printf("%d %d %d %d\n", o, p, q, r);
  }
  return 0;
}

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

using std::vector;

int match[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

vector<int> nums(int n, const vector<int>& ms) {
  vector<int> nn(n + 1, -1);

  nn[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int max = nn[i];
    for (const int m : ms) {
      if (i - m >= 0 && nn[i - m] != -1 && max < nn[i - m] + 1) {
	max = nn[i - m] + 1;
      }
    }
    nn[i] = max;
  }
  
  return nn;
}

int main(int argc, char* argv[]) {
  using std::cin;
  using std::cout;
  using std::endl;
  using std::find_if;
  
  int n, m;
  cin >> n >> m;
  vector<int> tmp(m);
  for (int i = 0; i < m; ++i) {
    cin >> tmp[i];
  }
  sort(tmp.begin(), tmp.end());

  vector<int> as;
  for (auto i = tmp.begin(); i < tmp.end(); ++i) {
    if (find_if(i + 1, tmp.end(),
		[i](int j){ return match[*i] == match[j]; }) == tmp.end()) {
      as.push_back(*i);
    }
  }
  
  vector<int> ms;
  for (auto a : as) {
    ms.push_back(match[a]);
  }
  const vector<int> nn = nums(n, ms);

  vector<int> mm;
  auto a = as.end();
  
  for (int i = n; i > 0;) {
    for (; a > as.begin(); --a) {
      if (i - match[*(a - 1)] >= 0 && nn[i] - 1 == nn[i - match[*(a - 1)]]) {
	mm.push_back(*(a - 1));
	i -= match[*(a - 1)];
	break;
      }
    }
  }

  for (auto i : mm) {
    cout << i;
  }

  return 0;
}


Measured memory_bytes: 384
def Technique_often_used():    
    # enumerate: for i, a in enumerate(a_list):
    # q, mod = divmod(a, b)
    # Functional Programming: filter, map, reduce
    pass
def naming_conventions():
    # if [s_1, s_2, s_3, ..., s_k] then I name this list sk
    # if [[s_11, s_12, ..., s_1k], ..,[s_j1, s_j2, ..., s_jk] then I name this list sjk
    # if there is something strange in a list then I add _ to the list's name (ex:sjk_)
    pass
def visual_studio_code_shortcut():    
    # visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
    # delete line: Ctrl+Shift+k
    # choose same words: Ctrl+Shift+l
    pass
from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html
from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from functools import reduce

from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers): #
    return reduce(lcm, numbers, 1)

# toggle test environment
is_test = False
def debug_print(value,comments="",is_test=is_test):
    # print() for test environment
    # debug_print([]) => []
    # debug_print("") => 
    # debug_print(a, "a is") => "a is:" print(a)
    if not is_test:
        pass
    elif not comments and value is None:
        print("")
    elif not comments:
        print(value)
    else:
        print(comments,":",value)

# set the inputs
if is_test:
    n,m = [10, 3]
    lr = [[3,6],[5,7],[6,9]]
else:        
    R = lambda: map(int, input().split())
    # ex1) n, k = R()
    # ex2) v = list(R())
    n,m = R()
    l,r = 0, 10**6
    for i in range(m):
        l_, r_ = R()
        l = max(l, l_)
        r = min(r, r_)

print(max(r-l+1,0))
    
# solve the problem


Measured memory_bytes: 5752
#include <bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mp make_pair

using namespace std;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	#ifdef PIYUSH_HOME
		I_O;
	#else
	#define print(...) 0
	#endif
	int d; cin >> d;
	int g; cin >> g;
	vector<int> p(d+1); std::vector<int> c(d+1); for (int o = 1; o <= d; ++o) { cin >> p[o]; cin >> c[o];}
	std::vector<int> v(d);
	for (int i = 0; i < d; ++i)
	{
		v[i] = i+1;
	}
	int ma = 1000000000;
	int tg = g;
	do {
		int t = 0;
		int i = 0;
		g = tg;
		while(g > 0)
		{
			if(g - (p[v[i]] * v[i] * 100 + c[v[i]]) >= 0)
			{
				t += p[v[i]];
				g -= (p[v[i]] * v[i] * 100 + c[v[i]]);
			}
			else
			{
				int j = g / (v[i] * 100) + (g % (v[i] * 100) ? 1 : 0);
				print(j);
				j = min(j, p[v[i]]);
				print(j);
				t += j;
				g = 0;
			}
			i++;
		}
		print(v, t);
		ma = min(ma, t);
	} while ( std::next_permutation(v.begin(), v.end()) );
	cout << ma;
}

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

int main() {
 int n,k;cin >> n >> k;
  vector<int> lngth(n);
  for(int i=0;i<n;i++){
  cin >> lngth[i];
  }
  sort(lngth.begin(),lngth.end(),greater<int>());
  int sum=0;
  for(int i=0;i<k;i++){
   sum+=lngth[i];
  }
   cout << sum << endl;
  
}

Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))

stack = []
ans = 'OK'
for i in range(n) :
    x = lst[i]
    if x > 0 :
        if x not in stack :
            stack.append(x) 
        else :
            print(i+1)
            ans = 'NG'
            break
    else :
        if len(stack) == 0 or stack[-1] != -x :
            print(i+1)
            ans = 'NG'
            break
        else :
            del stack[-1]
if ans == 'OK' :
    print(ans)


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

int main()
{
  int n;
  cin >> n;
  long long a[n];
  for(int i = 0; i < n; ++i) cin >> a[i];
  
  int num = 0;
  while(true)
  {
    bool flag = false;
    for(int i = 0; i < n; ++i)
    {
      if(a[i] % 2 == 0) a[i] /= 2;
      else flag = true;
    }
    if(flag) break;
    num++;
  }
  
  cout << num << endl;
}


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

using namespace std;

using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> asi(n), dp(n, 1e9);
  for (int i = 0; i < n; ++i) {
    cin >> asi[i];
  }
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (i - j < 0)
        break;
      dp[i] = min(dp[i - j] + abs(asi[i] - asi[i - j]), dp[i]);
    }
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1152
#include <iostream>


using namespace std;

int main(){
 string days[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
 string S;
 cin>>S;

 for(int i=0; i<7; i++){
   if ( S == days[i]){
     cout<<abs(i-7);
   }
 }
 
 

  return 0;
}

Measured memory_bytes: 256
A = input()
B = input()
C = input()
T = "a"
while  not ((A=="" and T=="a") or (B=="" and T=="b") or (C=="" and T=="c")):
  if T =="a":
    T = A[0]
    A = A[1:]
  elif T =="b":
    T = B[0]
    B = B[1:]
  elif T =="c":
    T = C[0]
    C = C[1:]
if (A=="" and T=="a"):
  print("A")
elif (B=="" and T=="b"):
  print("B")
elif (C=="" and T=="c"):
  print("C")

Measured memory_bytes: 3064
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		Integer N = Integer.parseInt(sc.next());
		Node v[] = new Node[N];
		int c[] = new int[N-1];
		for(int i=0;i<N;i++){
			v[i] = new Node(i);
		}
		Edge e[] = new Edge[N-1];
		for(int i=0;i<N-1;i++) {
			e[i] = new Edge(v[Integer.parseInt(sc.next())-1],v[Integer.parseInt(sc.next())-1],Integer.parseInt(sc.next()));
		}
		int Q = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		int x[] = new int[Q];
		int y[] = new int[Q];
		for(int i=0;i<Q;i++) {
			x[i] = Integer.parseInt(sc.next());
			y[i] = Integer.parseInt(sc.next());
		}
		
		Graph.search(v[K-1],v[K-1],0);



		long result = 0;
		for(int i=0;i<Q;i++) {
			result = v[x[i]-1].d + v[y[i]-1].d;
			out.println(result);
		}


		out.flush();
	}
}

class Node{
	int id;
	long d;
	Node prev = null;
	ArrayList<Edge> edges = new ArrayList<>();

	public Node(int id) {
		this.id = id;
		this.d = Integer.MAX_VALUE;
	}

	public void Reset() {
		this.d = Integer.MAX_VALUE;
		this.prev = null;
	}

	public void Reload_dist(long dist) {
		this.d = dist;
	}

	public void Reload_prev(Node v) {
		this.prev = v;
	}

	@Override public Node clone() {
		return new Node(this.id);
	}

	public void Connect(Edge e) {
		edges.add(e);
	}
}

class Edge{
	Node v1, v2;
	int cost;
	public Edge(Node id1,Node id2, int c) {
		this.v1 = id1;
		this.v2 = id2;
		this.cost = c;
		v1.Connect(this);
		v2.Connect(this);
	}

	public Node First_one() {
		return this.v1;
	}

	public Node Second_one() {
		return this.v2;
	}

	public Node Other_one(Node v) {
		if(v.equals(this.v1)) {
			return this.v2;
		}
		else {
			return this.v1;
		}
	}
}

class MyComparator implements Comparator<Node>{
	@Override public int compare(Node u,Node v) {

		int num1 = u.id;
		int num2 = v.id;
		if(num1 > num2) {
			return 1;
		}
		else if(num1 < num2) {
			return -1;
		}
		else {
			return 0;
		}
	}
}

class Graph{
	static Node[] nodes;
	static Edge[] edges;

	public Graph(Node[] v,Edge[] e) {
		Graph.nodes = v;
		Graph.edges = e;
	}

	public int size() {
		return nodes.length;
	}

	public boolean Bellman_Ford(Node s) {
		boolean negative_loop[] = new boolean[size()];
		Arrays.fill(negative_loop, false);
		s.Reload_dist(0);
		for(int i=0;i<size();i++) {
			for(Node v : nodes) {
				for(Edge e : v.edges) {
					if((v.d != Long.MAX_VALUE && e.Other_one(v).d > v.d + e.cost)) {
						e.Other_one(v).Reload_dist(v.d + e.cost);
						negative_loop[e.Other_one(v).id] = true;
					}
					if(i==size()-1) {
						return true;
					}
				}
			}
		}
		return false;
	}

	public static long search(Node current,Node from,long dist) {
		for(Edge e:current.edges) {
			Node searching = e.Other_one(current);
			if(searching!=from) {
				searching.Reload_dist(dist + e.cost);
				search(searching,current,searching.d);
			}
		}
		return current.d;
	}
}



Measured memory_bytes: 127896
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

const int dx[] = {1, -1, 0,  0};
const int dy[] = {0,  0, 1, -1};
char field[104][104];

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        for (int i=0; i<104; ++i) {
            for (int j=0; j<104; ++j) {
                if (i % 103 == 0 || j % 103 == 0) {
                    field[i][j] = '*';
                } else {
                    field[i][j] = '.';
                }
            }
        }
        for (int i=2; i<=m+1; ++i) {
            for (int j=2; j<=n+1; ++j) {
                cin >> field[i][j];
            }
        }
        bool ok = false;
        int k = 0;
        for (; !ok; ++k) {
            queue<pair<int,int> > q;
            q.push(make_pair(1,1));
            while ( ! q.empty() && ! ok) {
                int x = q.front().first;
                int y = q.front().second;
                q.pop();
                for (int i=0; i<4; ++i) {
                    if (field[y + dy[i]][x + dx[i]] == '&') {
                        ok = true;
                        break;
                    }
                    if (field[y + dy[i]][x + dx[i]] == '.') {
                        field[y + dy[i]][x + dx[i]] = '#';
                        q.push(make_pair(x + dx[i], y + dy[i]));
                    }
                }
            }
            if (ok) break;
            queue<pair<int,int> > q2;
            q2.push(make_pair(1,1));
            while ( ! q2.empty()) {
                int x = q2.front().first;
                int y = q2.front().second;
                q2.pop();
                for (int i=0; i<4; ++i) {
                    if (field[y + dy[i]][x + dx[i]] == '#') {
                        field[y + dy[i]][x + dx[i]] = '.';
                        q2.push(make_pair(x + dx[i], y + dy[i]));
                    }
                }
            }
        }
        cout << k << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
def main():
    labels = list(map(int, input().split(' ')))

    n = int(input())

    for i in range(n):
        dice = Dice(labels)
        t, f = map(int, input().split(' '))

        for j in range(8):
            if j%4 == 0:
                dice.toE()

            if f == dice.front:
                break

            dice.toN()

        for j in range(4):
            if t == dice.top:
                break
            dice.toE()

        print(dice.right)

class Dice:
    def __init__(self, labels):
        self.labels = labels

        self._tb = (0, 5)
        self._fb = (1, 4)
        self._lr = (3, 2)

    def toN(self):
        tb = self._tb
        self._tb = self._fb
        self._fb = tuple(reversed(tb))

        return self

    def toS(self):
        tb = self._tb
        self._tb = tuple(reversed(self._fb))
        self._fb = tb

        return self

    def toW(self):
        tb = self._tb
        self._tb = tuple(reversed(self._lr))
        self._lr = tb

        return self

    def toE(self):
        tb = self._tb
        self._tb = self._lr
        self._lr = tuple(reversed(tb))

        return self

    def get_top(self):
        return self.labels[self._tb[0]]

    def get_front(self):
        return self.labels[self._fb[0]]

    def get_right(self):
        return self.labels[self._lr[1]]

    top   = property(get_top)
    front = property(get_front)
    right = property(get_right)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7748
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

const ll MOD = 1000000007;
int main(){
    ll n, k;
    cin >> n >> k;
    ll zero = 0;
    vector<ll> pos, neg;
    for(ll i = 0; i < n; i++){
        ll a;
        cin >> a;
        if(a == 0) zero++;
        else if(a > 0) pos.push_back(a);
        else neg.push_back(-a);
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    if(pos.size() + (neg.size() & ~1) >= k && (pos.size() || ~k & 1)){
        reverse(pos.begin(), pos.end());
        reverse(neg.begin(), neg.end());
        ll a = k, b = 0;
        while(a - 2 >= 0 && b + 2 <= neg.size() && (a > pos.size() || pos[a - 1] * pos[a - 2] < neg[b] * neg[b + 1])){
            a -= 2;
            b += 2;
        }
        ll ans = 1;
        while(a--){
            ans *= pos[a];
            ans %= MOD;
        }
        while(b--){
            ans *= neg[b];
            ans %= MOD;
        }
        cout << ans << endl;
    }
    else if(zero) return !puts("0");
    else{
        ll a = k - 1, b = 1;
        while(a - 2 >= 0 && b + 2 <= neg.size() && (a > pos.size() || pos[a - 1] * pos[a - 2] > neg[b] * neg[b + 1])){
            a -= 2;
            b += 2;
        }
        ll ans = 1;
        while(a--){
            ans *= pos[a];
            ans %= MOD;
        }
        while(b--){
            ans *= neg[b];
            ans %= MOD;
        }
        if(ans) ans = MOD - ans;
        cout << ans << endl;
    }
}

Measured memory_bytes: 5500
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string s; cin >> s;
    int N = s.size();
    if(N == 2){
        if(s[0] == s[1]){
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }
    rep(i,N-3){
        if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

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

int main() {
  int a[50];
  int N, K, sum = 0;

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

  sort(a, a + N);

  for (int i = (N - K); i < N; i++){
    sum += a[i];
  }

  cout << sum << endl;

  return 0;
}

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


int cmp(const int *a,const int *b){

return *a > *b ? -1 : *a < *b ? 1 : 0 ;
}
//qsort(pa,n,sizeof(int),(int(*)(const void* ,const void*))cmp);

int main(void){
   int n;
   scanf("%d",&n);
   char s[n][100];
   int t[n];

   int i,j;
   for(i=0;i<n;i++){
     scanf("%s%d",s[i],&t[i]);
   }
   char x[100];
   scanf("%s",x);
   int no;

   for(i=0;i<n;i++){
     if(strcmp(x,s[i])==0){
       break;
     }
   }
   int ans=0;
   for(j=i+1;j<n;j++){
     ans+=t[j];
   }
   printf("%d",ans);




  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
	int n, m, temp, temp_;
	cin >> n >> m;
	
	pair <long long, long long> a[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> temp >> temp_;
		a[i] = make_pair(temp, temp_);
	}
	sort(a + 1, a + n + 1);
	
	long long sum = 0, cost = 0, i = 1;
	while (sum < m)
	{
		if (sum + a[i].second <= m) {cost += a[i].first*a[i].second; sum += a[i].second;} 
		else 
		{cost += a[i].first*(m - sum); break;}
		i++;
	}
	
	cout << cost;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

        long k = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        if (b <= a + 2) {
            System.out.println(1 + k);
            return;
        }

        long x = k - (a - 1);
        long ans = a + (x / 2) * (b - a) + (x % 2);

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

int main(void)
{
  int a, b, c, d, i, j, n, result;
  
  scanf("%d %d %d %d", &a, &b, &c, &d);

  
  for( i = 0; i < 1000; i++ ){
      c -= b;
      if( c < 1 ){
          printf("Yes\n");
          return 0;
      }
      a -= d;
      if( a < 1 ){
          printf("No\n");
          return 0;
      }
      
  }
  

  return 0;
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
int find(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return 0;
	}
	return 1;
}
int main(){
	int n;
	cin>>n;
	int k=3;
	while(n){
		if(find(k)&&k%10==1){
			cout<<k<<" ";
			n--;
		}
		k++;
	}
	return 0;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        q: usize,
        a: [usize; q],
    }
    let mut a = a;
    a.reverse();
    a.push(n);
    a.reverse();
    let mut h = std::collections::BinaryHeap::new();
    h.push((a[q], 1));
    for &a in a[0..q].iter().rev() {
        let mut y = 0;
        while let Some(&(len, cnt)) = h.peek() {
            if len <= a {
                break;
            }
            h.pop();
            y += (len / a) * cnt;
            if len % a != 0 {
                h.push((len % a, cnt));
            }
        }
        if y > 0 {
            h.push((a, y));
        }
    }
    let mut cnt = vec![0; n + 1];
    while let Some((l, c)) = h.pop() {
        cnt[0] += c;
        cnt[l] -= c;
    }
    for i in 1..(n + 1) {
        cnt[i] += cnt[i - 1];
    }
    for i in 0..n {
        writeln!(out, "{}", cnt[i]).unwrap();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 12540
var f = [];

function main(){
  for(var y=-2;y<12;y++){
    f[y] = [];
    for(var x=-2;x<12;x++){
      f[y][x] = 0;// initialize:undefined -> 0
    }
  }

  
  for(var i=0,len=input.length - 1;i<len;i++){
    var s = input[i].split(',');
    eval("d"+s[2]+"("+s[0]+","+s[1]+");");
  }

  var nd=0;//not dropped
  var md=0;//most dropped
  for(var y=0;y<10;y++){
    for(var x=0;x<10;x++){
      if(f[y][x] == 0)
        nd++;
      if(f[y][x] > md)
        md = f[y][x];
    }
  }

  console.log(nd);
  console.log(md);
}

function d1(x, y){
  f[y+1][x]++;
  f[y][x-1]++;
  f[y][x]++;
  f[y][x+1]++;
  f[y-1][x]++;
}

function d2(x, y){
  d1(x, y);
  f[y+1][x-1]++;
  f[y+1][x+1]++;
  f[y-1][x-1]++;
  f[y-1][x+1]++;
}

function d3(x, y){
  d2(x, y);
  f[y+2][x]++;
  f[y-2][x]++;
  f[y][x-2]++;
  f[y][x+2]++;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int x,y,n,d,s=0;
	cin>>n>>d;
	
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		if(x*x+y*y<=d*d) s++;
	}
	cout<<s;
	return 0;
}

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

typedef struct {
    int num[6], temp;
} dice_struct;
dice_struct dice;

void setting(int d[]) {
    for (int i = 0; i < 6; i++) {
        dice.num[i] = d[i];
    }
}

void throw_dice(char order) {
    switch (order) {
        case 'E':
            dice.temp = dice.num[0];
            dice.num[0] = dice.num[3];
            dice.num[3] = dice.num[5];
            dice.num[5] = dice.num[2];
            dice.num[2] = dice.temp;
            break;
        case 'S':
            dice.temp = dice.num[0];
            dice.num[0] = dice.num[4];
            dice.num[4] = dice.num[5];
            dice.num[5] = dice.num[1];
            dice.num[1] = dice.temp;
            break;
        case 'W':
            dice.temp = dice.num[0];
            dice.num[0] = dice.num[2];
            dice.num[2] = dice.num[5];
            dice.num[5] = dice.num[3];
            dice.num[3] = dice.temp;
            break;
        case 'N':
            dice.temp = dice.num[0];
            dice.num[0] = dice.num[1];
            dice.num[1] = dice.num[5];
            dice.num[5] = dice.num[4];
            dice.num[4] = dice.temp;
            break;            
    }
}

int main(int argc, char const *argv[]) {

    int number[6];
    for (int i = 0; i < 6; i++) {
        scanf("%d", &number[i]);
    }
    setting(number);

    string direction;
    cin >> direction;
    int len = direction.size();
    for(int i = 0; i < len; i++) {
        throw_dice(direction[i]);
    }

    cout << dice.num[0] << endl;
    return 0;
}



Measured memory_bytes: 3268
import fractions
 
N,X = map(int,input().split())
x = list(map(int,input().split()))
 
for n in range(N):
    x[n] = abs(x[n]-X)

if N == 1:
    ans = x[0]

else:
    ans = fractions.gcd(x[0],x[1])
    for n in range(2,N):
        ans = fractions.gcd(ans,x[n])

print(ans)

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

int main(){
  
  int N;
  cin >>N;
  vector<int> B(N-1);
  
  for(int i=0;i<N-1;i++){
    int x;
    cin >>x;
    B[i] = x;
  }
  
  int ans = 0;
  ans += B[0];
  ans += B[N-2];
  
  for(int i=1;i<N-1;i++){
    ans += min(B[i-1],B[i]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1LL<<50
#define MOD 1e9+7
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin>>x>>y;
    string ans="No";
    if((x==1 || x== 3 || x==5 || x==7 || x==8 || x==10 || x==12)
        && (y==1 || y== 3 || y==5 || y==7 || y==8 || y==10 || y==12)) ans="Yes";
    if((x==4 || x== 6 || x==9 || x==11)
        && (y==4 || y== 6 || y==9 || y==11)) ans="Yes";
    if(x==2 && y==2) ans="Yes";
    cout<<ans<<endl;
}

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

using namespace std;
int main() {
    int i, j, n, a, b, c, h, w;
    int count=0;

   cin >> h >> w;
   string s[h];
   string temp[h];
   for(i=0; i<h; i++){cin >> s[i];}
   for(i=0; i<h; i++){
       for(j=0; j<w; j++){
           if(s[i][j] == '#'){cout << "#";}
           else{
               if(i+1<=h) {if (s[i + 1][j] == '#')count++;}
               if(i+1<=h&&j+1<=w){if (s[i + 1][j + 1] == '#')count++;}
               if(i-1>=0){if (s[i - 1][j] == '#')count++;}
               if(j+1<=w){if (s[i][j + 1] == '#')count++;}
               if(j-1>=0){if (s[i][j - 1] == '#')count++;}
               if(i-1>=0&&j-1>=0){if (s[i - 1][j - 1] == '#')count++;}
               if(i+1<=h&&j-1>=0){if (s[i + 1][j - 1] == '#')count++;}
               if(i-1>=0&&j+1<=w){if (s[i - 1][j + 1] == '#')count++;}
                   cout << count;
           }

           count=0;
       }
       cout << endl;
   }

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a_list = list(map(int, input().split()))

a_set = list(set(a_list))
c = Counter(a_list)

if len(a_set) > n-2:
    print(0)
    exit()
else:
    a_list.sort(reverse=True)
    a_set.sort(reverse=True)
    candidate = []
    for i in a_set:
        cnt = c[i]
        
        if 2 <= cnt <= 3:
            candidate.append(i)
        elif cnt >= 4:
            candidate.append(i)
            candidate.append(i)
        if len(candidate) >= 2:
            print(candidate[0] * candidate[1])
            exit()


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    vector<int>L(n,0),R(n,0);
    for (int i=1;i<n;i++) {
        if(s[i-1]!='E'){
            L[i]++;
        }
        L[i]+=L[i-1];
    }
    for (int i=n-2;i>=0;i--) {
        if(s[i+1]!='W'){
            R[i]++;
        }
        R[i]+=R[i+1];
    }

    int ans=inf;
    rep(i,n){
        ans=min(ans,L[i]+R[i]);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3076
from collections import deque

a=deque(input())
b=list(input())
#print(a,b)
n=len(a)
#print(n)

flag=0
for i in range(n):
  list1=list(a)
  if list1==b:
    flag=1
  a.rotate(1)
  
print('Yes' if flag==1 else 'No')

Measured memory_bytes: 3316