akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	sc.nextInt()
	S := sc.nextStr()
	ans := 0
	for i := 0; i < 1000; i++ {
		key := strconv.Itoa(i)
		for len(key) < 3 {
			key = "0" + key
		}
		idx := 0
		for _, r := range S {
			if r == rune(key[idx]) {
				idx++
			}
			if idx == 3 {
				ans++
				break
			}
		}
	}
	fmt.Println(ans)
}


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



int main() {

	bool ans = true;
	int c = 0;
	string s;
	cin >> s;

	if (s[0] != 'A') {
		ans = false;
	}

	else {
		for (int i = 1; i < s.size(); i++) {

			if (1 < i && i < s.size() - 1) {
				if (s[i] == 'C')c++;
			}

			for (int j = 0; j < 25; j++) {
				string a = "ABDEFGHIJKLMNOPQRSTUVWXYZ";
				if (s[i] == a[j])ans = false;
			}
		}
	}

	if (c != 1)ans = false;

	if (ans == true)cout << "AC" << endl;
	else cout << "WA" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int d[1005][750];
int n,m,k,p;
vector<P>edge[1005];
int s[10],t[10];
int mask=1;
int main()
{
	cin >> n >> m >> k >> p;
	for(int i=0;i<m;i++)
	{
		int x,y,z; cin >> x >> y >> z;
		edge[x].pb(mp(y,z));
		edge[y].pb(mp(x,z));
	}
	for(int i=0;i<k;i++)
	{
		cin >> s[i] >> t[i]; mask=mask*3;
	}
	for(int i=0;i<1005;i++) for(int j=0;j<750;j++) d[i][j] = INF;
	d[p][0] = 0;
	priority_queue<P1,vector<P1>,greater<P1> >que;
	que.push(mp(0,mp(p,0)));
	while(!que.empty())
	{
		P1 p = que.top(); que.pop();
		if(p.fi != d[p.sc.fi][p.sc.sc]) continue;
		for(int i=0;i<edge[p.sc.fi].size();i++)
		{
			int cur = p.sc.sc;
			int nxt = cur;
			int pp = 1;
			int go = edge[p.sc.fi][i].fi;
			for(int x=0;x<k;x++)
			{
				int a = cur%3;
				cur /= 3;
				if(a == 2)
				{
					pp*=3;
				}
				else if(a==1 && t[x]==go)
				{
					nxt += pp;
					pp*=3;
				}
				else if(a==0 && s[x]==go)
				{
					nxt += pp;
					pp*=3;
				}
				else
				{
					pp*=3;
				}
			}
			if(d[go][nxt] > p.fi+edge[p.sc.fi][i].sc)
			{
				d[go][nxt] = p.fi+edge[p.sc.fi][i].sc;
				que.push(mp(d[go][nxt],mp(go,nxt)));
			}
		}
	}
	int res = INF;
	for(int i=1;i<=n;i++)
	{
		res = min(d[i][mask-1],res);
	}
	if(res == INF) puts("Cannot deliver");
	else printf("%d\n",res);
}

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

int n;

int main(){
  cin >> n;
  map<string, int> mp;
  int m = 0;
  rep(i, n){
    string s; cin >> s;
    mp[s]++;
    m = max(m, mp[s]);
  }
  for(auto x : mp){
    if(x.second == m){
      cout << x.first << "\n";
    }
  }
  
  return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;

ll mod = 1000000007;
ll n;
ll k;

vector<vector<ll>> multiply(const vector<vector<ll>>& a, const vector<vector<ll>>& b)
{
  ll s = a.size();
  ll t = a[0].size();
  
  ll u = b[0].size();
  vector<vector<ll>> c (s, vector<ll> (u));
  for (ll i = 0; i < s; i++)
  {
    for (ll j = 0; j < t; j++)
    {
      c[i][j] = 0;
      for (ll k = 0; k < s; k++)
        c[i][j] = (c[i][j] + (a[i][k]*b[k][j])%mod)%mod;
    }
  }
  return c;
}

vector<vector<ll>> power(vector<vector<ll>>& a, ll k)
{
  ll n = a.size();
  vector<vector<ll>> res (n, vector<ll> (n, 0));
  for (ll i = 0; i < n; i++)
  {
    res[i][i] = 1;
  }
  
  while (k > 0)
  {
    if (k&1)
    {
      res = multiply(res, a);
    }
    a = multiply(a, a);
    k = k >> 1;
  }
  return res;
}

int main()
{
  cin >> n >> k;
  vector<vector<ll>> graph (n, vector<ll> (n, 0));
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < n; j++)
      cin >> graph[i][j];
  graph = power(graph, k);
  ll result = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      result = (result + graph[i][j])%mod;
  cout << result % mod << endl;
  return 0;
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll MOD = 1000000007;

void solve() {

    ll n;
    cin >> n; 
    ll p[n];
    rep(i, n) cin >> p[i];
    priority_queue<ll,vector<ll>,greater<ll>> Q;
    ll result = 0;
    Q.push(n+1);
    rep(i,n) 
    {
        if(Q.top() > p[i]) ++result;
        Q.push(p[i]);
    }
    cout << result << endl;
    return;
}

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

}

Measured memory_bytes: 3956
import math

a, b, x = map(int, input().split())

if x / a <= a * b / 2:
  ad = 2 * x/(a * b)
  l = (b ** 2 + ad ** 2) ** 0.5
  res = math.degrees(math.acos(ad/l))
else:
  ad = (a * b - x / a) * 2 / a
  l = (a ** 2 + ad ** 2) ** 0.5
  res = 90 - math.degrees(math.acos(ad/l))
  
print(res)

Measured memory_bytes: 3060
// 177

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long int;
#define NUM 1000000007

ll modpow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % NUM;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % NUM;
        n >>= 1;  // n を1bit 左にずらす
    }
    return res;
}

int main(){
    ll n, ans;
    cin >> n;
    ans = (modpow(10, n) - 2 * modpow(9, n) + modpow(8, n))%NUM;
    if(ans < 0) ans = NUM + ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace  std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 2e5 + 5;
ll n , m , k,A[N],B[N] , PA[N] , PB[N];

int main() {
    fastIO;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> B[i];
    }
    for(int i = 0 ; i<n ; i++){
        PA[i+1] = PA[i] + A[i];
    }
    for(int i = 0 ; i<m ; i++){
        PB[i+1] = PB[i] + B[i];
    }
    int ans =0 ;
    for(int i = 0 ; i<=n ; i++){
        if(k-PA[i]<0)break;
        ll val = k - PA[i];
        int l = 0 , r = m+1;
        while(l+1<r){
            int mid = (l+r)/2;
            if(PB[mid]<=val){
                l = mid ;
            }
            else{
                r = mid ;
            }
        }
        ans = max(ans,l+i);
    }
    cout<<ans;

}



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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e9;
const double EPS = 1e-9;
const ll MOD = (ll)(1e9 + 7);
const ll MAXV = (ll)(2e5 + 10);
const ll MAXE = (ll)(1e6 + 10);



int main(){
	cin.sync_with_stdio( 0 );cin.tie( 0 );

	ll n;

	cin >> n;

	string s;

	cin >> s;

	ll cnt = 0, ans = 1;

	bool ok = true;

	for(int i = 0;i < 2*n;i ++){
		int curr;
		if(s[i] == 'B')
			curr = 1LL;
		else
			curr = 0LL;

		if((cnt + curr) % 2LL)
			cnt ++;
		else{
			ans = (ans * cnt) % MOD;
			cnt --;
		}
		if(cnt < 0){
			ok = false;
			break;
		}
	}

	ll fact = 1LL;
	for(ll i = 1;i <= n;i ++)
		fact = (fact * i) % MOD;

	ans = (ans * fact) % MOD;

	if(cnt != 0)
		ok = false;

	if(ok)
		cout << ans << "\n";
	else
		cout << "0\n";

	return 0;
}


Measured memory_bytes: 720
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
const int MAX_V = 10000;

int V, E;
vi G[MAX_V];
int deg[MAX_V];
bool used[MAX_V];

void solve() {
   queue<int> que;

   for (int i = 0; i < V; i++) {
       if (deg[i] == 0) que.push(i);
   }

   while (!que.empty()) {
       int v = que.front(); que.pop();
       cout << v << endl;

       for (auto to : G[v]) {
           deg[to]--;

           if (deg[to] == 0) que.push(to);
       }
   }
}

int main() {
    cin >> V >> E;
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;

        G[s].push_back(t);
    }

    for (int i = 0; i < V; i++) {
        for (auto to : G[i]) {
            deg[to]++;
        }
    }

    solve();
}

Measured memory_bytes: 1896
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc159_b();
	}
  
  	public static void solve_abc159_b(){

		Scanner sc = new Scanner(System.in);
		boolean ans = true;

		String s1 = sc.next();
		StringBuilder sb1  = new StringBuilder(s1);
		String a1 = sb1.reverse().toString();

		String s2 = s1.substring(0, (s1.length()-1)/2);
		StringBuilder sb2  = new StringBuilder(s2);
		String a2 = sb2.reverse().toString();

		String s3 = s1.substring((s1.length()+3)/2 - 1);
		StringBuilder sb3  = new StringBuilder(s3);
		String a3 = sb3.reverse().toString();

		if(!s1.equals(a1)) ans = false;
		if(!s2.equals(a2)) ans = false;
		if(!s3.equals(a3)) ans = false;

		if(ans) System.out.println("Yes");
		else System.out.println("No");

		sc.close();

	}
}

Measured memory_bytes: 21972
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

import java.util.LinkedList;
import java.util.Scanner;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
		for(int i = 0; i < adjMatrix.length; i++) {
			for(int j = 0; j < adjMatrix[0].length; j++) {
				adjMatrix[i][j] = 0;
			}
		}
		int position = 0;
		for( LinkedList<Integer> vertex : adjList) {
				if(!vertex.isEmpty()) {
					for(int edge : vertex) {
						adjMatrix[position][edge] = 1;
					}
				}
				position++;
		}
		for ( int i = 0; i < totalVertex; i++) {
			String num = ""; 
			for(int j = 0; j < totalVertex; j++) {
				num += adjMatrix[i][j];
				if (j < totalVertex - 1) {
					num += " ";
				}
			}
			System.out.println(num);
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 48872
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    p = min(a[i],b[i])
    a[i] -= p
    ans += p
    q = min(b[i] - p, a[i+1])
    a[i+1] -= q
    ans += q
print(ans)


Measured memory_bytes: 19648
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    vector<int> vA1(N+1, 0); for(int i=1; i<=N; ++i){ int tmp;cin>>tmp; vA1[i]=vA1[i-1]+tmp; }
    vector<int> vA2(N+1, 0); for(int i=1; i<=N; ++i){ int tmp;cin>>tmp; vA2[i]=vA2[i-1]+tmp; }
    
    int sum=0;
    for(int i=1; i<=N; ++i){
        int s1 = vA1[i]-vA1[0];   // (0, i] -> [1, i]
        int s2 = vA2[N]-vA2[i-1]; // (i-1, N] -> [i, N]
        sum = max(sum, s1+s2);
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace aizuoj
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (input == null) break;

                int a = Int32.Parse(input.Split(' ')[0]);
                int b = Int32.Parse(input.Split(' ')[1]);

                Console.WriteLine((a + b).ToString().Length);
            }
            
        }
    }
}



Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
using I = long long;
int main() {
  int Q;
  cin >> Q;
  for(auto i=0; i<Q; ++i) {
    I A, B;
    cin >> A >> B;
    if(A > B) swap(A, B);
    I S = A*B;
    I s = sqrt(S);
    if(1<s && s*s == S) --s;
    I r = 2 * s;
    I a = s;
    I b = S/a;
    if(a*b == S) --b;
    if(a == b) {
      r -= 2;
      if(A!=a&&B!=b) ++r;
    } else if(a == A) {
      r -= 2;
      if(b!=A&&a!=B) ++r;
    }
    if(A < s) {
      a = A;
      b = S/a;
      r -= 2;
      if(b!=A&&a!=B) ++r;
    }
    cout << r << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

ll a[N],c=0;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<ll> cn;
	vector<int> arr(n);
	int xr = 0;
	f(i,0,n){
		cin >> arr[i];
		xr = xr^arr[i];
	}
	sort(all(arr));
	int cc = 1;

	f(i,1,n){
		if(arr[i] == arr[i-1]){
			cc++;
		}else{
			cn.pb(cc);
			cc = 1;
		}
		if(i==n-1){
			cn.pb(cc);
		}
	}
	sort(all(cn));
	if(n==3){
		if(arr[1]^arr[2] == arr[0]){
			cout << "Yes\n";
		}else{
			cout << "No\n";
		}
		return 0;
	}
	f(i,0,n+1){
		a[i] = -1;
	}
	f(i,0,n){
		if(a[i]==-1 and a[(i+3)%n] == -1){
			a[i] = ++c;
			a[(i+3)%n] = c;
		}else if(a[i]==-1){
			a[i] = a[(i+3)%n];
			// a[(i+3)%n] = a[i];
		}else if(a[(i+3)%n]== -1){
			// a[i] = a[(i+3)%n];
			a[(i+3)%n] = a[i];
		}
		// cout << a[i] << ' ';
	}
	map<ll,ll> cnt;
	f(i,0,n){
		++cnt[a[i]];
	}
	int j = 0;
	vector<ll>temp;
	for(auto &el : cnt){
		temp.pb(el.S);
	}
	sort(all(temp));
	// f(i,0,temp.size()){
	// 	cout << temp[i] << ' ';
	// }
	// cout <<'\n';
	// f(i,0,cn.size()){
	// 	cout << cn[i] <<' ';
	// }
	// if(temp == cn){
	// 	cout << "Yes\n";
	// }else{
	// 	cout << "No\n";
	// }
	if(xr == 0){
		cout <<"Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}

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

int main (){
	int ch;
	while(cin>>ch){
		switch(ch){
			case 25:
				cout << "Christmas\n";
				break;
			case 24:
				cout<<"Christmas Eve\n";
				break;
			case 23:
				cout<<"Christmas Eve Eve\n";
				break;	
			case 22:
				cout<<"Christmas Eve Eve Eve\n";
				break; 
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long int;

// to format a document: ctrl + K -> ctrl + D

int main() {

    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < 4; i++) {
        if (S[i] == '+')
            ++ans;
        else
            --ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int h=sc.nextInt();
		int w=sc.nextInt();
		int a[][]=new int [h][w];
		int count=0;
		String m[]=new String[h*w];
		for (int i=0;i<h;++i){
			for (int j=0;j<w;++j){
				a[i][j]=sc.nextInt();
			}
		}

		for (int i=0;i<h;++i){
			for (int j=0;j<w-1;++j){
				if (a[i][j]%2==1){
					--a[i][j];
					++a[i][j+1];

					m[count]=((i+1)+" "+(j+1)+" "+(i+1)+" "+(j+2));
					++count;
				}
			}
			if (a[i][w-1]%2==1 && i!=h-1){
				--a[i][w-1];
				++a[i+1][w-1];
				m[count]=((i+1)+" "+w+" "+(i+2)+" "+w);
				++count;
			}
		}

		System.out.println(count);

		for (int i=0;i<count;++i){
			System.out.println(m[i]);
		}


	}
}

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


int main() {
	int n,A[252];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>A[i];
	}
	for(int i=1;i<=n;i++){
		printf("node %d: key = %d, ",i,A[i]);
		if(i/2>=1){
			printf("parent key = %d, ",A[i/2]);
		}
		if(i*2<=n){
			printf("left key = %d, ",A[i*2]);
		}
		if(i*2+1<=n){
			printf("right key = %d, ",A[i*2+1]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3228
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define loopi(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) loopi(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // #define endl "\n"
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max()/10;

int popcount(unsigned long long x){
    return __builtin_popcount(x);
    static int dp[66000];
    if(dp[1] == 0){
        for(int i = 0; i < 65536; i++) dp[i] = (i&1) + dp[i>>1];
    }
    int res = 0;
    while(x) res += dp[x&0xffff], x >>= 16;
    return res;
}

int solve(ll s, ll d){
    //if(s <= 0 && d >= 0) return __builtin_popcount(-s) + __builtin_popcount(d);
    if(s <= 0 && d >= 0) return popcount(-s) + popcount(d);
    else if(s >= 0 && d >= 0){
        int j = 0;
        int ans = 0;
        while(s < d){
            if((s>>j&1) && (d>>j&1)){
                s += 1LL<<j;
                d -= 1LL<<j;
                ans += 2;
            } else if((s>>j&1) ^ (d>>j&1)){
                s += 1LL<<j;
                ans ++;
            }
            j++;
        }
        return ans;
    } else return solve(-d,-s);
}

signed main(){
    fastios();
    int N;
    cin >> N;
    rep(i,N){
        ll s,d;
        cin >> s >> d;
        cout << solve(s,d) << endl;
    }
}

Measured memory_bytes: 1204
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/

	a, b := nextInt(), nextInt()
	if (a*b)%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w;
int a[252][252];
vector<pii> g[52525];
int bef[52525];
int dist[52525];
int used[52525];

#define ID(i,j) ((i)*w+j)
#define REV(i,j,v) int i=v/w, j=v%w

const int NICO = 125252;
const int INF = 830252521;

int main(){
  scanf("%d%d",&h,&w);
  REP(i,h)REP(j,w)scanf("%d",&a[i][j]);
  // start : (0,0)
  // goal : (h,w)

  // first flow
  REP(i,h)REP(j,w){
    if(i<h-1){
      g[ID(i,j)].push_back(pii(ID(i+1,j),NICO-a[i+1][j]));
    }
    if(j<w-1){
      g[ID(i,j)].push_back(pii(ID(i,j+1),NICO-a[i][j+1]));
    }
  }
  REP(i,w*h)dist[i] = INF;
  priority_queue<pii> Q;
  dist[0] = 0;
  Q.push(pii(-0,0));
  while(!Q.empty()){
    pii P = Q.top(); Q.pop();
    int d = -P.first;
    int id = P.second;
    for(pii X:g[id]){
      int to = X.first;
      int cost = X.second;
      if(d+cost < dist[to]){
        dist[to] = d+cost;
        bef[to] = id;
        Q.push(pii(-dist[to],to));
      }
    }
  }
  ll first_attempt = (ll)(w+h-2)*NICO-dist[w*h-1];
  // second construct
  int cur = w*h-1;
  REP(i,w*h)used[i] = -1;
  REP(i,w*h)g[i].clear();
  while(cur!=0){
    // DEBUG(cur);
    int par = bef[cur];
    used[par] = cur;
    REV(i,j,cur);
    g[cur].push_back(pii(par,a[i][j]-NICO));
    if(i>0 && par == ID(i-1,j)){
      if(j>0){
        g[ID(i,j-1)].push_back(pii(par,0));
      }
    }else{
      if(i>0){
        g[ID(i-1,j)].push_back(pii(par,0));
      }
    }
    a[i][j] = 0;
    cur = par;
  }
  REP(i,h)REP(j,w){
    if(i<h-1 && used[ID(i,j)]!=ID(i+1,j)){
      g[ID(i,j)].push_back(pii(ID(i+1,j),NICO-a[i+1][j]));
    }
    if(j<w-1 && used[ID(i,j)]!=ID(i,j+1)){
      g[ID(i,j)].push_back(pii(ID(i,j+1),NICO-a[i][j+1]));
    }
  }
  REP(i,w*h)dist[i] = INF;
  dist[0] = 0;
  Q.push(pii(-0,0));
  while(!Q.empty()){
    pii P = Q.top(); Q.pop();
    int d = -P.first;
    int id = P.second;
    for(pii X:g[id]){
      int to = X.first;
      int cost = X.second;
      if(d+cost < dist[to]){
        dist[to] = d+cost;
        bef[to] = id;
        Q.push(pii(-dist[to],to));
      }
    }
  }
  // cur = w*h-1;
  // while(cur!=0){
  //   DEBUG(cur);
  //   cur = bef[cur];
  // }
  ll second_attempt = (ll)(w+h-2)*NICO-dist[w*h-1];
  // DEBUG(first_attempt);
  // DEBUG(second_attempt);
  printf("%lld\n",first_attempt+second_attempt - a[h-1][w-1]+a[0][0]);
  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s, s1, s2,ans;
    int i1, i2;
    cin >> s;
    s1 = s.substr(0,2);
    s2 = s.substr(2,2);
    i1 = stoi(s1);
    i2 = stoi(s2);
    if((i1 > 12) || (i1 < 1)){
      if((i2 > 12) || (i2 < 1)){
        ans = "NA";
      }else{
        ans = "YYMM";
      }
    }else{
      if((i2 > 12) || (i2 < 1)){
        ans = "MMYY";
      }else{
        ans = "AMBIGUOUS";
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        exec();
    }

    static void exec() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        double m = sc.nextDouble();

        BigDecimal b = BigDecimal.valueOf(n);
        BigDecimal c = BigDecimal.valueOf(m);
        System.out.println(b.multiply(c).setScale(0, BigDecimal.ROUND_DOWN));
    }
}

Measured memory_bytes: 29232
N = int(input())


def sum_of_num(num):
    list_a = []
    sums = 0
    while num > 0 :
        list_a.append(num % 10)
        num = num //10
    for i in range(len(list_a)):
        sums = sums + list_a[i]
    return sums

fx = sum_of_num(N)

if N % fx == 0:
    print('Yes')
if N % fx != 0:
    print('No')

Measured memory_bytes: 9132
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
	get_number(A),
    get_number(B),
    X is max(max(A + B, A - B), A * B),
    writeln(X).


Measured memory_bytes: 8172
#include<bits/stdc++.h>
using namespace std;
int main (){
    int K,b,c;
  cin>>K;
  
    vector<int>a(K);
    for(int i=0;i<K;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    b=K/2;
    c=a[b]-a[b-1];
    cout<<c<<endl;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        x: Chars,
    }

    let mut c1 = 0usize;
    for &e in &x {
        if e == '1' {
            c1 += 1;
        }
    }

    let mut c = vec![0; 2];
    if c1 == 0 {
        for _ in 0..n {
            println!("1");
        }
        return;
    } else if c1 == 1 {
        let mut vec = Vec::new();
        for i in (0..n).rev() {
            if x[i] == '1' {
                vec.push(0);
            } else {
                if i == n - 1 {
                    vec.push(2);
                } else {
                    vec.push(1);
                }
            }
        }
        for e in vec.into_iter().rev() {
            println!("{}", e);
        }
        return;
    }
    c[0] = c1 - 1;
    c[1] = c1 + 1;

    let mut base = vec![0; 2];
    for i in 0..n {
        for j in 0..2 {
            if c[j] == 0 {
                continue;
            }
            base[j] = base[j] << 1 | if x[i] == '1' { 1 } else { 0 };
            base[j] %= c[j];
        }
    }

    let mut pow = vec![1 % c[0], 1 % c[1]];
    let mut vec = Vec::new();
    for i in (0..n).rev() {
        let mut r = if x[i] == '1' {
            (base[0] + c[0] - pow[0]) % c[0]
        } else {
            (base[1] + pow[1]) % c[1]
        };
        let mut count = 1usize;
        while r > 0 {
            r %= r.count_ones() as usize;
            count += 1;
        }
        vec.push(count);
        for j in 0..2 {
            pow[j] *= 2;
            pow[j] %= c[j];
        }
    }
    for e in vec.into_iter().rev() {
        println!("{}", e);
    }
}


Measured memory_bytes: 4724
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vll> vl2d;
typedef vector <vi> vi2d;
typedef vector <char> vc;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <long,long> ml;
typedef map <string,string> mss;
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define foreach(x,arr) for(auto& x:arr)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define endl '\n' // Normal `cout << endl` flushes the output every time wich hit performance badly
#define INF 1000000000LL
#define MOD 1000000007
#define deb(x) cout<<#x<<": "<<x<<endl;
#define printArray(arr) for(auto x: arr) { cout<<x<<"\n"; }
#define printMatrix(mat) for(auto x: mat) { cout<<" "; printArray(x); cout<<endl; }
#define printMap(mmap) for(auto p: mmap) { cout<< p.first<<": "<<p.second<<endl; }
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define forch(ch,str) for(char& c : str)
#define FILL(a,b) memset(a,b,sizeof(a))
//Swift related stuff
#define append push_back
#define nil nullptr
#define guard(_condition) if (bool(_condition)){}
#define count size()
#define let const auto
#define var auto
#define startsWith(str) rfind(str, 0)
#define prq priority_queue
#define tostr(argument) to_string(argument)
#define alphabet "abcdefghijklmnopqrstuvwxyz"

void join(const vector<string>& v, char c, string& s) {

   s.clear();

   for (vector<string>::const_iterator p = v.begin();
        p != v.end(); ++p) {
      s += *p;
      if (p != v.end() - 1)
        s += c;
   }
}

unordered_map<int, vector<int>> graph;
int n;
ll mod = 1e9 + 7;

void dfs(int v, int p, vector<ll> &dpw, vector<ll> &dpb) {
    dpw[v] = 1;
    dpb[v] = 1;
    
    foreach(n, graph[v]) {
        guard(n != p) else {
            continue;
        }
        dfs(n,v,dpw,dpb);
        dpw[v] = (dpw[v] * (dpb[n]+dpw[n])%mod)%mod;
        dpb[v] = (dpb[v] * dpw[n])%mod;
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); // Fast input
    
    cin>>n;
    rep(i,0,n-1) {
        int s,d;
        cin>>s>>d;
        graph[s].push_back(d);
        graph[d].push_back(s);
    }
    vector<ll> dpw(n+1, 0), dpb(n+1, 0);
    dfs(1,0, dpw, dpb);
    cout<<(dpw[1] + dpb[1])%mod<<endl;
    return 0;
}


Measured memory_bytes: 19056
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;

class Card
{
public:
    char Mark;
    int num;
};

void trace(Card *A, int N) {
    for ( int i = 0; i < N; ++i ) {
        if ( i > 0 ) {
            cout << ' ';
        }
        cout << A[i].Mark << A[i].num;
    }
    cout << endl;
}

void swap(Card *a, Card *b) {
    int temp_num;
    char temp_Mark;
    temp_num = (*a).num;
    temp_Mark = (*a).Mark;
    (*a).num = (*b).num;
    (*a).Mark = (*b).Mark;
    (*b).num = temp_num;
    (*b).Mark = temp_Mark;
}

int BubbleSort(Card *A, int N) {
    int flag = 0;
    int sw = 0;
    int cnt = 0;
    do {
        flag = 0;
        for (int i = N - 1; i > cnt; --i) {
            if (A[i].num < A[i - 1].num) {
                swap(&A[i], &A[i - 1]);
                sw++;
                flag = 1;
            }
        }
        cnt++;
    }while ( flag == 1 );
    return sw;
}

int SelectionSort(Card *A, int N) {
    int mini;
    int cnt = 0;
    for ( int i = 0; i < N; ++i ) {
        mini = i;
        for ( int j = i; j < N; ++j ) {
            if ( A[mini].num > A[j].num ) {
                mini = j;
            }
        }
        if ( A[mini].num < A[i].num) {
            swap(&A[mini], &A[i]);
            cnt++;
        }
    }
    return cnt;
}

int main() {
    Card A[MAX],B[MAX];
    int N;
    int ans;

    cin >> N;
    for ( int i = 0; i < N; ++i ) {
        cin >> A[i].Mark >> A[i].num;
        B[i].Mark = A[i].Mark;
        B[i].num = A[i].num;
    }



    BubbleSort(A,N);
    trace(A,N);
    cout << "Stable" << endl;

    SelectionSort(B,N);
    trace(B,N);

    for ( int i = 0; i < N; ++i ) {
        if ( A[i].Mark != B[i].Mark ) {
            cout << "Not stable" << endl;
            return 0;
        }
    }
    cout << "Stable" << endl;


    return 0;
}


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

int main() {
  string S;
  cin >> S;
  string ans = "";
  for (int b = 0; b < (1 << 3); b++) {
    int res = S.at(0) - '0';
    string formula = to_string(res);
    for (int i = 0; i < S.size() - 1; i++) {
      if (b & (1 << i)) {
        formula += '+';
        res += S.at(i + 1) - '0';
      } else {
        formula += '-';
        res -= S.at(i + 1) - '0';
      }
      formula += S.at(i + 1);
    }

    if (res == 7) {
      cout << formula + "=7" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3668
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

// ref.
// https://qiita.com/tnoda_/items/b503a72eac82862d30c6
var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	l := make([]int, n)
	r := make([]int, n)
	for i := range a {
		a[i] = nextInt()
	}
	for i := range a {
		if i >= n-1 {
			break
		}
		l[i+1] = gcd(l[i], a[i])
	}
	for i := range a {
		if i >= n-1 {
			break
		}
		r[len(r)-i-2] = gcd(r[len(r)-i-1], a[len(r)-i-1])
	}
	ans := 1
	for i := range l {
		ans = max(ans, gcd(l[i], r[i]))
	}

	fmt.Println(ans)

}


Measured memory_bytes: 4736
# coding:utf-8
import math


def h_degree(h, m):
    return (h*60 + m) * 0.5


def m_degree(m):
    return m * 6


A, B, H, M = map(int, input().split(' '))
d = abs(h_degree(H, M) - m_degree(M))

if d == float(0):
    print(abs(A - B))

elif d == float(180):
    print(A + B)

else:
    if d > 180:
        d = 360 - d
    C2 = (A ** 2) + (B ** 2) - (2 * A * B * math.cos(math.radians(d)))
    print(math.sqrt(C2))


Measured memory_bytes: 9520
import itertools
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]

for x,y in itertools.product(range(W),range(H)):
    if S[y][x]==".":
        res=0
        for i,j in itertools.product(range(-1,2),range(-1,2)):
            if 0<=x+i and x+i<W and 0<=y+j and y+j<H:
                if S[y+j][x+i]=="#":
                    res+=1
        
        S[y][x]=res

for j in range(H):
    L=[str(a) for a in S[j]]
    print(''.join(L))

Measured memory_bytes: 9164
from sys import stdin
from collections import deque

d = deque()

S = stdin.readline().rstrip().split()
Q = [int(x) for x in stdin.readline().rstrip().split()]

d.append(S[0])
# print(d)
flag = 0b0

for i in range(Q[0]):
    s = input().split()

    if len(s) == 1:
        # print(len(d[0]))
        if len(d) == 1 and len(d[0]) == 1:
            pass
        else:
            flag = ~flag

        #     if len(d[0])!=:
        #         flag = ~flag
        # if len(d[0]) != 1:
        #     flag = ~flag
            # print(flag)
        # flag = ~flag
        # S=S[::-1]
        # d.reverse()

    else:
        if int(s[1]) == 1:
            if flag == 0:
                d.appendleft(s[2])
            else:
                s[2] = s[2][::-1]
                # print(s[2])
                d.append(s[2])
                # print(d)
            # d.appendleft(s[2])
            # S.insert(0,s[2])

        else:
            if flag == 0:
                d.append(s[2])
            else:
                s[2] = s[2][::-1]
                # print(s[2])
                d.appendleft(s[2])
            # d.append(s[2])
            # S.append(s[2])
# print(flag)
ans = "".join(d)
# print(ans)
if flag == -1:
    ans = ans[::-1]
    # d.reverse()
    # print(d)

# print("".join(d))
print(ans)


Measured memory_bytes: 11756
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 100010

using namespace std;

int n, d, x, a;

int main()
{
	cin >> n >> d >> x;
	
	for(int i = 1; i <= n; i++) {
		cin >> a;
		x += (d-1)/a+1;
	}
	
	cout << x;
}

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

int main() {
	int n;
	cin >> n;
	vector<string> da(n);
	for (int i = 0;i < n;i++) {
		cin >> da[i];
	}
	bool ju_A=false;
	int ans = 0;
	int co_A = 0, co_B = 0;
	for (int i = 0;i < n;i++) {
		int x = da[i].size()-1;
		for (int j = 0;j < x;j++) {
			if (da[i][j] == 'A') {
				if (da[i][j + 1] == 'B') {
					ans++;
				}
			}
		}
		if (da[i][0] == 'B') {
			co_B++;
			if (da[i][x] != 'A')
				ju_A = true;
		}
		if (da[i][x]=='A')
			co_A++;
	}
	ans += min(co_A, co_B);
	if (!ju_A&&co_A==co_B&&!(co_A==0))
		ans--;
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
using namespace std;
int n,k,p[1005],sum;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%d",p+i);
	}
	sort(p+1,p+1+n);
	for(int i=1;i<=k;++i){
		sum+=p[i];
	}
	printf("%d\n",sum);
	return 0;
}


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

if n==2:
    print(b[0]*2)
else:
    ans=[0]*n
    ans[0]=b[0]
    ans[n-1]=b[-1]
    for i in range(1,n-1):
        ans[i]=min(b[i],b[i-1])
    print(sum(ans))

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int n;
     cin >> n;
     vi v(n);
     for(int i=0;i<n;i++)cin >> v[i];
     sort(all(v),greater<int>());
     ll ans =0;
     ans += v[0];
     int cnt=0;
     int j =1;
     for(int i=2;i<n;i++){
         ans += v[j];
         cnt++;
         if(cnt==2)j++,cnt=0;
     }
     cout << ans;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3984
import java.util.*;

public class Main {
	String s;
	int id;
	
	int A(){
		ArrayList<Integer> list = new ArrayList<Integer>();

		while(true){
			if(s.charAt(id)=='['){
				id++;
				list.add(A());
				id++;
			}else{
				int t = id;
				while(48<=s.codePointAt(id) && s.codePointAt(id)<=57) id++;
				int u = Integer.valueOf(s.substring(t,id));
				list.add(u/2+1);
			}
			if(id==s.length() || s.charAt(id)==']') break;
		}
		
		Collections.sort(list);
		int sum = 0;
		for(int i=0;i<=list.size()/2;i++) sum += list.get(i);
		return sum;
	}

	void solve(){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for(int i=0;i<n;i++){
			s = sc.next();
			id = 0;
			System.out.println(A());
		}
	}
	
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

Measured memory_bytes: 41876
import java.util.*;
import java.io.*;
public class Main {
   static class pair implements Comparable<pair>{
        int a;
        long b;
        public pair(int a, long b){
            this.a=a;
            this.b=b;
        }
        public int compareTo(pair p){
            return (a-p.a==0)?Long.compare(b,p.b):a-p.a;
        }
          
   }
  public static void main(String[] args) throws IOException,InterruptedException{
	BufferedReader	 br = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
     	// String s = br.readLine();
        // char[] arr=s.toCharArray();
        // ArrayList<Integer> arrl = new ArrayList<Integer>(); 
        // TreeSet<Integer> ts1 = new TreeSet<Integer>(); 
        // HashSet<Integer> h = new HashSet<Integer>(); 
        // HashMap<Integer, Integer> map= new HashMap<>(); 
        // PriorityQueue<String> pQueue = new PriorityQueue<String>(); 
        // LinkedList<String> object = new LinkedList<String>(); 
        // StringBuilder str = new StringBuilder();
        
        //*******************************************************//
 	   //  StringTokenizer   st = new StringTokenizer(br.readLine());
 	   // 	  int t = Integer.parseInt(st.nextToken());
 	   //    while(t-->0){
 	   //        st = new StringTokenizer(br.readLine());
 	   // 	  int n = Integer.parseInt(st.nextToken());
 	   // 	  int[] arr = new int[n];
 	   // 	  st = new StringTokenizer(br.readLine());
 	   // 	  for(int i=0; i<n; i++){
 	   // 	      arr[i] =Integer.parseInt(st.nextToken());
 	   // 	  }
 	   // 	  int ans =0;
 	   // 	  out.println(ans);
 	   //    }
 	         StringTokenizer   st = new StringTokenizer(br.readLine());
 	    	  n = Integer.parseInt(st.nextToken());
 	    	  w = Integer.parseInt(st.nextToken());
 	    	 arr = new char[n][w];
 	    	 for(int i=0; i<n; i++){
 	    	    arr[i] = br.readLine().toCharArray();
 	    	 }
 	    	 dp = new long[n+5][w+5];
 	    	 for(int i=0; i<n+5; i++) Arrays.fill(dp[i],-1l);
 	    	 out.println(solve(0,0)%mod);
              out.flush();
 	    	  }
 	    	  static int mod = (int) 1e9+7;
 	    	  static int n;
 	    	  static int w;
 	    	  static long[][] dp;
 	    	  static char [][] arr;
              public static long solve(int i, int j){
                  if(i==n-1&&j==w-1) return 1l;
                  if(i>=n||j>=w) return 0l;
                  if(arr[i][j]=='#') return 0l;
                  if(dp[i][j]!=-1) return dp[i][j];
                  return dp[i][j] = (solve(i+1,j)%mod+solve(i,j+1)%mod)%mod;
              }
	}
	
	


Measured memory_bytes: 38020
#include <iostream>
#include<cmath>

using namespace std;

int main()
{
    int h,a;
    cin>>h>>a;
    int counter=0;
    for(int i=0 ; i<10e4 ; i++)
    {
        if(h!=0 &&h>0) { h=h-a; counter++;}
        else break;
    }

    cout<<counter;
}

Measured memory_bytes: 256