akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True

ans=0


a=I()


ans=2*a*3.14159265
print(ans)






Measured memory_bytes: 76532
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int64_t i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int64_t i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int64_t i = beg; end <= i; i--)

using namespace std;

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

	int64_t n; cin >> n;

	int64_t aval[3]; cin >> aval[0] >> aval[1] >> aval[2];
	int64_t bval[3]; cin >> bval[0] >> bval[1] >> bval[2];

	int64_t cs[4] = { n, 0, 0, 0 };

	int64_t max_n = n;
	{
		// A -> B
		{
			int64_t imax = 0;
			if (bval[0] > aval[0]) imax = n / aval[0];
			FOR_LE(i, 0, imax) {
				int64_t r = n - i * aval[0];

				int64_t jmax = 0;
				if (bval[1] > aval[1]) jmax = r / aval[1];
				FOR_LE(j, 0, jmax) {
					int64_t k = 0;
					int64_t r2 = r - j * aval[1];
					if (bval[2] > aval[2]) {
						k = r2 / aval[2];
					}
					int64_t r3 = r2 - k * aval[2];

					max_n = max(max_n, r3 + i * bval[0] + j * bval[1] + k * bval[2]);
				}
			}
		}

		bool unchanged = n == max_n;

		n = max_n;
		// B -> A
		if (unchanged) {
			int64_t imax = 0;
			if (aval[0] > bval[0]) imax = n / bval[0];
			FOR_LE(i, 0, imax) {
				int64_t r = n - i * bval[0];

				int64_t jmax = 0;
				if (aval[1] > bval[1]) jmax = r / bval[1];
				FOR_LE(j, 0, jmax) {
					int64_t k = 0;
					int64_t r2 = r - j * bval[1];
					if (aval[2] > bval[2]) {
						k = r2 / bval[2];
					}
					int64_t r3 = r2 - k * bval[2];

					max_n = max(max_n, r3 + i * aval[0] + j * aval[1] + k * aval[2]);
				}
			}
		}
		else {
			int order[3] = { 0, 1, 2 };
			int c = 0;
			if (aval[0] > bval[0]) {
				order[c] = 0;
				c++;
			}
			if (aval[1] > bval[1]) {
				order[c] = 1;
				c++;
			}
			if (aval[2] > bval[2]) {
				order[c] = 2;
				c++;
			}

			if (c == 1) {
				int64_t num = max_n / bval[order[0]] * aval[order[0]];
				max_n = max_n % bval[order[0]] + num;
			}
			else {
				int64_t max_prev = max_n;

				int64_t d = bval[order[0]] * bval[order[1]];
				
				int64_t maxi = min(d / bval[order[0]], max_prev / bval[order[0]]);
				FOR_LE(i, 0, maxi) {
					int64_t o0c = i;
					int64_t r = max_prev - o0c * bval[order[0]];

					int64_t o1C = r / bval[order[1]];
					int64_t r2 = r - o1C * bval[order[1]];

					max_n = max(max_n, r2 + o0c * aval[order[0]] + o1C * aval[order[1]]);
				}

				int64_t mini = max(maxi, (max_prev - d) / bval[order[0]]);
				FOR_LE(i, mini, max_prev / bval[order[0]]) {
					int64_t o0c = i;
					int64_t r = max_prev - o0c * bval[order[0]];

					int64_t o1C = r / bval[order[1]];
					int64_t r2 = r - o1C * bval[order[1]];


					max_n = max(max_n, r2 + o0c * aval[order[0]] + o1C * aval[order[1]]);
				}
			}
		}
	}

	cout << max_n << endl;

	return 0;
}


Measured memory_bytes: 256
# D　イロハちゃんと升目
cnt=0
h,w,a,b=map(int,input().split())
def find_power(n):
    # 0!からn!までのびっくりを出してくれる関数
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(10**9+7)
    return powlist

def find_inv_power(n):
    #0!からn!までの逆元を10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

powlist=find_power(h+w+1)
invlist=find_inv_power(h+w+1)
def combi(n,r):
    a=powlist
    b=invlist
    if n<r:
        return 0
    elif n>=r:
        return (a[n]*b[r]*b[n-r])%(10**9+7)

for i in range(h-a):
    cnt+=(combi(b+i-1,i)*combi(w+h-2-b-i,h-1-i))%(10**9+7)
print(cnt%(10**9+7))
    


Measured memory_bytes: 26740
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int main() {
    int a[6];
    for (int i=0; i<6; i++) {
        cin >> a[i];
    }
    int n;
    cin >> n;
    int x,y;
    for (int i=0; i<n; i++) {
        cin >> x >> y;
        if(x==a[0]){
            if(y==a[1]){
                cout <<a[2];
            }
            if(y==a[2]){
                cout <<a[4];
            }
            if(y==a[3]){
                cout <<a[1];
            }
            if (y==a[4]) {
                cout <<a[3];
            }
        }
        if(x==a[1]){
            if(y==a[0]){
                cout <<a[3];
            }
            if(y==a[2]){
                cout <<a[0];
            }
            if(y==a[3]){
                cout <<a[5];
            }
            if (y==a[5]) {
                cout <<a[2];
            }
        }
        if(x==a[2]){
            if(y==a[1]){
                cout <<a[5];
            }
            if(y==a[5]){
                cout <<a[4];
            }
            if(y==a[4]){
                cout <<a[0];
            }
            if (y==a[0]) {
                cout <<a[1];
            }
        }
        if(x==a[3]){
            if(y==a[1]){
                cout <<a[0];
            }
            if(y==a[0]){
                cout <<a[4];
            }
            if(y==a[4]){
                cout <<a[5];
            }
            if (y==a[5]) {
                cout <<a[1];
            }
        }
        if(x==a[4]){
            if(y==a[2]){
                cout <<a[5];
            }
            if(y==a[5]){
                cout <<a[3];
            }
            if(y==a[3]){
                cout <<a[0];
            }
            if (y==a[0]) {
                cout <<a[2];
            }
        }
        if(x==a[5]){
            if(y==a[2]){
                cout <<a[1];
            }
            if(y==a[4]){
                cout <<a[2];
            }
            if(y==a[1]){
                cout <<a[3];
            }
            if (y==a[3]) {
                cout <<a[4];
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define r(i, n) for (ll i=0;i<n;i++)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
bool primeNumber(ll n){
    if(n < 2) return true;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return true;
        }
        return false;
    }
}
int main() {
  llc(n);
  bool a=true;
  while(a) {
    a=primeNumber(n);
    n++;
  }
  cout << n-1 << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())

    count = 0
    found = {}
    for _ in range(n):
        strs = list(input())
        strs.sort()
        str = ''.join(strs)
        if str in found:
            count += found[str]
            found[str] += 1
        else:
            found[str] = 1

    print(count)


if __name__ == "__main__":
    main()


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

using namespace std;

using ll = long long;

constexpr int mx[] = {-1, 0, 1};
constexpr int my[] = {-1, 0, 1};
ll ans[10] = {};

int main() {
  ll h, w;
  int n;
  cin >> h >> w;
  cin >> n;
  map<pair<ll, ll>, int> mp;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    for (const auto &x : mx) {
      for (const auto &y : my) {
        mp[{a + x - 1, b + y - 1}]++;
      }
    }
  }
  ll al = (h - 2) * (w - 2);
  for (const auto &m : mp) {
    auto p = m.first;
    if (p.first <= 0 || p.second <= 0)
      continue;
    if (p.first >= h - 1 || p.second >= w - 1)
      continue;
    // cout << p.first << p.second << m.second << endl;
    ans[m.second]++;
    --al;
  }
  ans[0] = al;
  for (int i = 0; i < 10; ++i) {
    cout << ans[i] << endl;
  }
}

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

#define LLD_SPEC "%lld"

int main() {
    int n, q;
    scanf("%d%d", &n, &q);

    vector<long long> a;

    a.push_back(n);

    for (int i = 0; i < q; ++i) {
        long long x;
        scanf(LLD_SPEC, &x);

        while (a.size() > 0 && a.back() >= x) {
            a.pop_back();
        }

        a.push_back(x);
    }

    vector<long long> vls;
    for (int i = 1; i < a[0]; ++i) {
        vls.push_back(i);
    }
    for (int i = 0; i < (int) a.size(); ++i) {
        vls.push_back(a[i]);
    }

    vector<long long> cfs(vls.size(), 0);
    ++cfs[cfs.size() - 1];

    for (int i = (int) cfs.size() - 1; i >= a[0]; --i) {
        long long rem = vls[i];

        while (rem > 0) {
            int bl = 0;
            int br = i - 1;
            int ba = 0;

            while (bl <= br) {
                int bm = (bl + br) >> 1;

                if (vls[bm] <= rem) {
                    ba = bm;
                    bl = bm + 1;
                } else {
                    br = bm - 1;
                }
            }

            cfs[ba] += cfs[i] * (rem / vls[ba]);
            rem %= vls[ba];
        }
    }

    vector<long long> result(n, 0);
    for (int i = 0; i < a[0]; ++i) {
        result[i] = cfs[i];
    }

    for (int i = a[0] - 1; i > 0; --i) {
        result[i - 1] += result[i];
    }

    for (int i = 0; i < n; ++i) {
        printf(LLD_SPEC "\n", result[i]);
    }

    return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll K;
  scanf("%lld", &K);

  ll odd = 1 + (K - 1) / 2;
  ll even = K / 2;

  ll ans = odd * even;

  cout << ans << endl;
}


Measured memory_bytes: 3672
from collections import defaultdict
n, x, y = map(int, input().split())
x -= 1
y -= 1

# d = defaultdict(list)
d = defaultdict(int)
for i in range(n-1):
    for j in range(i+1, n):
        distance = j - i
        if i <= x and y <= j:
            # 順方向で順方向で近道できるとき
            distance -= y - x - 1
        # distance2 = 10 ** 10
        # if x <= i <= y and x <= j <= y:
        distance2 = abs(i - x) + abs(y - j) + 1
        # if i == 1 and j == 3:
        #     print('hoge')
        #     print(i)
        #     print(x)
        #     print(y)
        #     print(j)
        #     print('hoge')
        #     print(distance2)
        distance = min(distance, distance2)

        # d[distance].append((i, j, distance))
        d[distance] += 1

for i in range(1, n):
    print(d[i])

# for i, j in d.items():
#     print(i)
#     print(j)
#     print()


Measured memory_bytes: 3956
K, N = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
dist = [0 for i in range(N + 10)]
for i in range(1, N):
  dist[i] = A[i] - A[i - 1]
dist[0] = A[0] + (K - A[-1])
max_dist = max(dist)
res = sum(dist) - max_dist
print(res)

Measured memory_bytes: 26444
<?php

class Scanner
{
  private $arr = [];
  private $count = 0;
  private $pointer = 0;

  public function next()
  {
    if ($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    ++$this->pointer;

    return $result;
  }

  public function hasNext()
  {
    return $this->pointer < $this->count;
  }

  public function nextInt()
  {
    return (int) $this->next();
  }

  public function nextDouble()
  {
    return (float) $this->next();
  }
}

$sc = new Scanner();
$n = $sc->nextInt();
$array=[];
$sum = 0;

for($i=0;$i<$n;$i++){
  $array[] = $sc->nextInt();
}

for($i=0;$i<$n-2;$i++){
  $flag = 0;
  if($array[$i+1] > $array[$i]){
    $flag += 1;
  }
  if($array[$i+1] > $array[$i+2]){
    $flag += 1;
  }
  if($flag == 1){
    $sum++;
  }
}

echo $sum . PHP_EOL;


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

typedef long long ll;

vector<ll> r(100);
vector<ll> c(100);
vector<vector<ll>> dp(101, vector<ll>(101,-1));

ll solve(ll a, ll b)
{
    if(dp.at(a).at(b) != -1){
        return dp.at(a).at(b);
    }
    if(b-a == 1){
        return dp.at(a).at(b) = 0;
    }else if(b-a == 2){
        return dp.at(a).at(b) = r.at(a)*c.at(a)*c.at(b-1);
    }else{
        vector<ll> tmp;
        ll i;
        for(i = a+1;i <= b-1;++i){
            ll tmp1 = solve(a, i);
            ll tmp2 = solve(i, b);
            tmp.push_back(tmp1 + tmp2 + r.at(a)*r.at(i)*c.at(b-1));
        }
        sort(tmp.begin(), tmp.end());
        return dp.at(a).at(b) = tmp.front();
    }
}

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    for(i = 0;i < n;++i){
        cin >> r.at(i) >> c.at(i);
    }
    ll ans = solve(0,n);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string said_before[n], last_string, curr_string;
    cin >> last_string;
    for (int i = 0; i < n - 1; i++) {
        said_before[i] = last_string;
        cin >> curr_string;
        if (last_string[last_string.length() - 1] != curr_string[0]) {
            cout << "No";
            return 0;
        }
        for (int j = i; j >= 0; j--) {
            if (curr_string == said_before[j]) {
                cout << "No";
                return 0;
            }
        }
        last_string = curr_string;
    }
    cout << "Yes";
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007 
#define MM 998244353
using namespace std;
 
int main()
{
	int a, b;

	cin >> a >> b; 

	if ( a < 10 && b < 10)
	{
		cout << a*b;
	}
	else
	{
		cout << -1;
	}

  	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define int long long
#define debug(var) cout << "[" << #var << "] " << var << endl
//using ll = long long;

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> map(h, vector<char>(w));
    vector<vector<int>> count(h, vector<int>(w));

    rep(i, h) {
        vector<char> tmp(w);
        vector<int> tmp_count(w, 0);
        rep(j, w) {
            cin >> tmp.at(j);
        }
        map[i] = tmp;
        count[i] = tmp_count;
    }

    if (map[0][0] == '.') {
        count[0][0] = 0;
    } else {
        count[0][0] = 1;
    }
    FOR(j, 1, w) {
        if (map[0][j-1] == '.' && map[0][j] == '#') {
            count[0][j] = count[0][j-1] + 1;
        } else {
            count[0][j] = count[0][j-1];
        }
    }
    FOR(i, 1, h) {
        if (map[i-1][0] == '.' && map[i][0] == '#') {
            count[i][0] = count[i-1][0] + 1;
        } else {
            count[i][0] = count[i-1][0];
        }
    }

    FOR(i, 1, h) {
        FOR(j, 1, w) {
            int up, left;

            if (map[i][j-1] == '.' && map[i][j] == '#') {
                left = count[i][j-1] + 1;
            } else {
                left = count[i][j-1];
            }

            if (map[i-1][j] == '.' && map[i][j] == '#') {
                up = count[i-1][j] + 1;
            } else {
                up = count[i-1][j];
            }

            count[i][j] = min(left, up);
        }
    }

    // rep(i, h) {
    //     rep (j, w) {
    //         cout << count[i][j];
    //     }
    //     cout << endl;
    // }

    cout << count[h-1][w-1];

}

Measured memory_bytes: 384
/* ALDS1_9_C: Priority Queue */

#include <iostream>
#include <cstdio>

const int MAX_N_NODES = 2000000;

class PriorityQueue {
    int size;
    int *heap;
    void max_heapify(int heap[], int i);
    int parent(int i);
    int left(int i);
    int right(int i);
    public:
        PriorityQueue();
        ~PriorityQueue();
        void insert(int key);
        int extract_max();
};

PriorityQueue::PriorityQueue() {
    size = 0;
    heap = new int[ MAX_N_NODES + 1 ];
}

PriorityQueue::~PriorityQueue() {
    delete [] heap;
}

int PriorityQueue::parent(int i) {
    return i / 2;
}

int PriorityQueue::left(int i) {
    return i * 2;
}

int PriorityQueue::right(int i) {
    return i * 2 + 1;
}

void PriorityQueue::insert(int key) {
    size++;
    heap[size] = key;

    int i = size;
    while (1 < i && heap[parent(i)] < heap[i]) {
        std::swap(heap[parent(i)], heap[i]);
        i = parent(i);
    }
}

int PriorityQueue::extract_max() {
    int max = heap[1];
    heap[1] = heap[size];
    size--;
    max_heapify(heap, 1);

    return max;
}

void PriorityQueue::max_heapify(int heap[], int i) {
    int il = left(i);
    int ir = right(i);

    int max_i = i;
    if (il <= size && heap[i] < heap[il])
        max_i = il;
    if (ir <= size && heap[max_i] < heap[ir])
        max_i = ir;

    if (max_i != i) {
        std::swap(heap[i], heap[max_i]);
        max_heapify(heap, max_i);
    }
}

int main() {
    PriorityQueue pq;
    int key;
    char command[7];

    while(true) {
        scanf("%s", command);
        if (command[0] == 'i') { // insert
            scanf("%d", &key);
            pq.insert(key);
        }
        else if (command[1] == 'x') { // extract
            printf("%d\n", pq.extract_max());
        }
        else { break; }
    }
    return 0;
}

Measured memory_bytes: 5628
//ラウンドロビンスケジューリング
//2018-12-17
//Ebitani Akira

#include<stdio.h>

#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = ( tail + 1 ) % LEN;
  
}

P dequeue(){
  P x = Q[head];
  head = ( head + 1 ) % LEN;
  return x;

}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n + 1;

  while( head != tail ){
    u = dequeue();
    if(q > u.t ){
      c = u.t;
    }

    else{
      c = q;
    }
    
    u.t = u.t - c;
    elaps = elaps + c;

    if( u.t > 0 ){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }
    

  
  return 0;
}



Measured memory_bytes: 11864
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, q = na()
s = ns()
su = [0] * (n + 1)

ac = 0
if s[0] =="A":
    ac = 1
for i in range(1, n):
    si = s[i]
    if si == "A":
        ac = 1

    elif si =="C" and ac == 1:
        su[i] = 1
        ac = 0
    else:
        ac = 0
    su[i] += su[i-1]




l, r = [], []
for _ in range(q):
    li, ri = na()
    l.append(li)
    r.append(ri)

for i in range(q):
    print(su[r[i]-1] - su[l[i]-1])


Measured memory_bytes: 15840
A,B = map(int,input().split())
"""#失敗
answer = (A + B) // 2# //で切り捨て除算
print(answer)
if A + B % 2 == 0:
    print(A+B/2)
else:
    print("IMPOSSIBLE")
"""

if (A + B) % 2 == 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 2940
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

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

bool is_even(int n) { return n % 2 == 0; }
bool is_odd(int n)  { return n % 2 == 1; }

unsigned long long dp_ev[100][100];
unsigned long long dp_od[100][100];

void dp()
{
#if 0
    dp_ev[0][0] = 1;
    dp_od[0][0] = 0;

    dp_ev[1][0] = 2;
    dp_od[1][0] = 0;

    dp_ev[0][1] = 1;
    dp_od[0][1] = 1;
#endif

    for(unsigned long long a = 0; a <= 50; ++a) {
        dp_ev[a][0] = 1ULL << a;
        dp_od[a][0] = 0;
    }

    for(unsigned long long b = 1; b <= 50; ++b) {
        dp_ev[0][b] = dp_od[0][b-1] + dp_ev[0][b-1];
        dp_od[0][b] = dp_od[0][b-1] + dp_ev[0][b-1];
    }

    for(unsigned long long a = 1; a <= 50; ++a) {
        for(unsigned long long b = 1; b <= 50; ++b) {
            dp_ev[a][b] = dp_od[a][b-1] + dp_ev[a][b-1];
            dp_od[a][b] = dp_od[a][b-1] + dp_ev[a][b-1];
        }
    }
}

int main()
{
    dp();

    int n, p;
    cin >> n >> p;

    vector<int> a(n);
    REP(i, n) {
        cin >> a[i];
    }

    int n_even = count_if(begin(a), end(a), is_even);
    int n_odd  = count_if(begin(a), end(a), is_odd);

    unsigned long long result;
    if(p == 1) {
        result = dp_od[n_even][n_odd];
    }
    else {
        result = dp_ev[n_even][n_odd];
    }

    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a!=1&&b!=1){
        printf("1");
    }
    else if(a!=2&&b!=2){
        printf("2");
    }
    else if(a!=3&&b!=3){
        printf("3");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
int main(){
//FASTIO
ll n,k;
cin>>n>>k;
vector<double> a(n);
for(int i=0;i<n;i++){
	cin>>a[i];
}
double s=0;
for(int i=0;i<k;i++){
    s+=a[i];
}
double p=k;
double q=((p)*(p-1.0))/(2.0);
double ans;
ans=(((s*(s+1.0))/(2.0))-q)/(s-p+1);
for(int i=k;i<n;i++){
	s-=a[i-k];
	s+=a[i];
   	ans=max(ans,(((s*(s+1.0))/(2.0))-q)/(s-p+1));
} 
printf("%0.7f",ans);
return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> L(N);
  for(int i = 0; i < N; i++) cin >> L[i];
  
  sort(L.begin(), L.end());
  
  int count = 0;
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      int ok = j;
      int ng = N;
      while(ng - ok > 1){
        int k = (ok + ng) / 2;
        (L[k] < L[i] + L[j] ? ok : ng) = k;
      }
      
      count += ok - j;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000
int n;

int main(){
    cin >> n;
    int l[n]; rep(i,n) cin >> l[i]; 
	int ans = 0;
	sort(l,l+n);
    
    for(int i = 0; i < n; i++){
    	for(int j = i+1; j < n-1; j++){
    		int ab = l[i] + l[j];
    		int a = lower_bound(l,l+n,ab)  -l;
    		int path = j+1;

    		ans+=max(0,a-path);
    	}
    }
     cout << ans << endl;
    return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
 
  int n,m,l;
  scanf("%d %d %d", &n, &m, &l);
 
  int i,j,a[n][m];
   
  for ( i = 0 ; i < n ; i++ ){
    for ( j = 0 ; j < m ; j++ ){
      scanf("%d", &a[i][j]);
    }
  }
 
  int b[m][l];
 
  for ( i = 0 ; i < m ; i++ ){
    for( j = 0 ; j < l ; j++ ){
      scanf("%d", &b[i][j]);
    }    
  }
 
  long sum,c[n][l];
  int k;
  sum =0;
 
  for ( i = 0 ; i < n ; i++ ){
    for ( j = 0 ; j < l ; j++ ){
      for ( k = 0 ; k < m ; k++ ){
 
    sum = sum + a[i][k] * b[k][j];
 
      }
 
      c[i][j] = sum;
      sum = 0;
 
    }
  }
 
  for ( i = 0 ; i < n ; i++ ){
    for ( j = 0 ; j < l ; j++ ){
 
      printf("%ld", c[i][j]);
 
      if ( j == l - 1 ){
    printf("\n");
    break;
      }
 
      printf(" ");
       
    }
     
  }
 
  return 0;
   
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int X,Y,Z;
LL A[100001];
LL B[100001];
LL C[100001];
bool used[100001];
typedef pair<LL,LL> P;
vector<P>v;
LL dp[100001];
LL dp2[100001];


LL ans=0;
int main(){
   cin>>X>>Y>>Z;
   REP(i,X+Y+Z){
       cin>>A[i]>>B[i]>>C[i];
       v.push_back(P(A[i]-C[i],i));
   }
   sort(v.begin(),v.end(),greater<P>());
   priority_queue<LL>que;
   REP(i,X){
       int num=v[i].second;
       dp[0]+=A[num];
       que.push(B[num]-A[num]);
   }
   for(int i=1;i<=Y;i++){
       int num=v[X+i-1].second;
       que.push(B[num]-A[num]);
       LL a=que.top();que.pop();
       dp[i]=a+dp[i-1]+A[num];
   }
   priority_queue<LL>que2;
   for(int i=X+Y+Z-1;i>=X+Y;i--){
       int num=v[i].second;
       dp2[0]+=C[num];
       que2.push(B[num]-C[num]);
   }
   for(int i=1;i<=Y;i++){
       int num=v[X+Y-i].second;
       que2.push(B[num]-C[num]);
       LL a=que2.top();que2.pop();
       dp2[i]=a+dp2[i-1]+C[num];
   }
   LL aaa=0;
   REP(i,Y+1){
       //cout<<dp[i]<<" "<<dp[Y-i]<<" "<<dp[i]+dp[Y-i]<<endl;
       aaa=max(aaa,dp[i]+dp2[Y-i]);
   }
   cout<<aaa<<endl;
   return(0);
}

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

int main(){
  int n, i, j = 0;
  cin >> n;
  for(i = 1; i < n+1; i++){
    if(((to_string(i)).length()) % 2 == 1){
      j++;
    }
  }
  cout << j << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int n;
    int sum=0;
    int a;
    scanf("%d",&n);
    
    a=n;
    while(n){
        sum+=n%10;
        n/=10;
    }
    

    if(a%sum==0){
        printf("Yes");
    }else{
        printf("No");
    }
    
    return 0;
    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    lli H,W,m =1000000007;
    cin >> H>>W;
    char arr[H+1][W+1];
    lli dp[H+1][W+1];
    for(lli i=0;i<H;i++)
    {
        for(lli j=0;j<W;j++)
        {
            cin >> arr[i][j];
            dp[i][j]=0;
        }
    }
    dp[H-1][W-1]=1;
         
    for(int i=H-1;i>=0;i--)
    {
        for(int j = W-1;j>=0;j--)
        {
            if(arr[i][j] != '#')
            {
                if(i!=H-1)
                    dp[i][j] += dp[i+1][j];
                if(j!=W-1)
                    dp[i][j]+=dp[i][j+1];

                dp[i][j] %=m;
            }        
        }
    }
    cout << dp[0][0] << endl;

}

Measured memory_bytes: 9088
a, b = map(int, input().split())
c = []
for i in range(a):
    c.append(list(input().replace(".", "0")))
for i in range(a):
    for j in range(b):
        if c[i][j] == "#":
            for x in range(i-1, i+2):
                for y in range(j-1, j+2):
                    if 0 <= x <= a-1 and 0 <= y <= b-1 and c[x][y] != "#":
                        c[x][y] = str(int(c[x][y]) + 1)
for i in range(a):
    print("".join(c[i]))


Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cassert>
#include<random>
#include<fstream>
#include<chrono>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int          long long
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define rep(i,s,e)   for(int i=(s);i<=(e);i++)
#define brep(i,s,e)  for(int i=(s);i>=(e);i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define VR46         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);ifstream fin("ip.txt");ofstream fout("op.txt");
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25); // less_equal
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7;
const int INF = 0x3F3F3F3F3F3F3F3F;
ld EPS = 1e-12;

signed main()
{
    VR46 // GANDU TEST CASE BNALE
    // int t;cin>>t;rep(test,1,t)
    {
        string s;
        cin>>s;
        bool a = false, b = false;
        rep(i,0,2) s[i]=='A' ? a = true : b = true;
        if( a && b ) cout<<"Yes\n";
        else cout<<"No\n";
    }
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  for(;;){
    if(x->left==NIL){
      break;
    }
    else{
      x=x->left;
      return x;
    }
  }
}

Node treeMaximum(Node x){
  for(;;){
    if(x->right==NIL){
      break;
    }
    else{
      x=x->right;
      return x;
    }
  }
}

Node treeSearch(Node u, int k){

}
Node treeSuccessor(Node x){
  
}
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(1){
  if(x==NIL){
      break;
    }
    else{
      y=x;
      if(x->key < z->key){
    x=x->right;
      }
      else{
    x=x->left;
      }
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
  if(z->key < y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }
  }
}

void inorder(Node u){
  if( u == NIL ) return ;
  inorder( u->left );
  printf(" %d",u->key);
  inorder( u->right );
}
void preorder(Node u){
  if( u == NIL ) return ;
  printf(" %d",u->key);

  preorder( u->left );
  preorder( u->right );
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25168
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  string S;
  cin >> S;
  ll ct=0,cs=0;
  rep(i,S.size()){
    if(S[i]=='S'){
      cs++;
    }
    else{
      ct++;
      if(cs>0){
        cs--;
        ct--;
      }
    }
  }
  cout << cs+ct << endl;
}

Measured memory_bytes: 640
from itertools import permutations
import math
p=permutations(range(5))
l=[int(input()) for i in range(5)]
ans=10**10
for pi in p:
    res=0
    for i in range(5):
        if i==4:
            res+=l[pi[i]]
        else:
            res+=math.ceil(l[pi[i]]/10)*10
    ans=min(ans, res)
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF (int)1e18
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int A[404],dp[404][404];
int32_t main(){
    boost;
    //freopen(".in","r",stdin);
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i)
        cin>>A[i];
    for (int i = n-1; i >= 0; i--)
        for (int j = i+1; j < n; ++j)
        {
            dp[i][j]=INF;
            int s=0;
            for (int z = i; z <= j; ++z)s+=A[z];
            for (int z = i; z < j; ++z)
                dp[i][j]=min(dp[i][j],dp[i][z]+dp[z+1][j]+s);
        }
    cout<<dp[0][n-1]<<"\n";
    return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 4852
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	int n;cin>>n;if(n%1000==0) cout<<"0\n"; else cout<<1000-n%1000<<endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    int N, D;

    cin >> N >> D;

    int coverage = D * 2 + 1;
    
    int num_overseers = N / coverage;
    if (N % coverage != 0){
        num_overseers++;
    }

    cout << num_overseers << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int a,b,c,count=0;
     cin>>a>>b>>c;
     for(int i=b;i<=c;i++)
     {
          if(i%a==0)
          {
               count++;
               break;
          }

     }
     if(count>0)
          cout<<"OK";
     else
          cout<<"NG";
     return 0;

}


Measured memory_bytes: 3636
#include <iostream>
const int INF=1e9;
using namespace std;
int main(){
  int d[100][100],n,p;
  cin>>n;
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) d[i][j]=INF;
  for(int i=0,r,k,t;i<n&&cin>>r>>k;i++) for(int j=0;j<k&&cin>>t;j++) d[r-1][t-1]=1;
  for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) d[i][j]++;
  cin>>p;
  for(int i=0,s,t,v;i<p;i++){
    cin>>s>>t>>v;
    if(d[s-1][t-1]>v) cout<<"NA"<<endl;
    else cout<<d[s-1][t-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3124
import math

def distance(l1,l2):
    d2 = 0
    for i in range(len(l1)):
        l = l1[i] - l2[i]
        d2 += l ** 2
    return d2

def issqrt(num):
    cand = int(math.sqrt(num))
    if (cand + 1) ** 2 == num:
        return True
    if cand ** 2 == num:
        return True
    if (cand - 1) ** 2 == num:
        return True
    return False


N,D = map( int, input().split())
cord = []
for _ in range( N ):
    xlist = list(map(int,input().split()))
    cord.append( xlist )

count = 0
for i in range( N - 1):
    for j in range( i+1, N):
        d = distance( cord[i],cord[j])
        #print( "({} {}) => {} {}".format(i,j,d,math.sqrt(d)))
        if issqrt( d ):
            count += 1

print( count )


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	string s;
	cin >> s;
	int cnt=0;
	rep(i,s.size()){
		if(i==0) continue;
		if(s[i-1]!=s[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <functional>

template <typename T, typename U>
struct LazySegTree {
  std::function<T (T, T)> op;
  T id;
  std::function<U (U, U)> lazy_op;
  U lazy_id;
  std::function<T (U, int)> lazy_apply;

  int n;

  std::vector<T> node;
  std::vector<T> lazy_node;

  LazySegTree(std::function<T (T, T)> _op, T _id, std::function<U (U, U)> _lazy_op, U _lazy_id, std::function<T (U, int)> _lazy_apply, std::vector<T> valvec) {
    op = _op;
    id = _id;
    lazy_op = _lazy_op;
    lazy_id = _lazy_id;
    lazy_apply = _lazy_apply;

    for (n = 1; n < valvec.size(); n *= 2);

    node.resize(2*n-1);
    for (int i = 0; i < valvec.size(); i++) node[n-1+i] = valvec[i];
    for (int i = valvec.size(); i < n; i++) node[n-1+i] = id;
    for (int i = n-2; i >= 0; i--) node[i] = op(node[2*i+1], node[2*i+2]);

    lazy_node.resize(2*n-1);
    for (int i = 0; i < 2*n-1; i++) lazy_node[i] = 1000000000;
  }

  void eval(int k, int l, int r) {
    node[k] = std::min(node[k], lazy_node[k]);
    if (k < n-1) {
      lazy_node[2*k+1] = std::min(lazy_node[2*k+1], lazy_node[k]);
      lazy_node[2*k+2] = std::min(lazy_node[2*k+2], lazy_node[k]);
    }
    lazy_node[k] = 1000000000;
  }

  T op_range(int a, int b) { return op_range(a, b, 0, 0, n); }
  T op_range(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return id;

    eval(k, l, r);

    if (a <= l && r <= b) return node[k];
    return op(op_range(a, b, 2*k+1, l, (l+r)/2), op_range(a, b, 2*k+2, (l+r)/2, r));
  }

  void update_range(int a, int b, T val) { return update_range(a, b, val, 0, 0, n); }
  void update_range(int a, int b, T val, int k, int l, int r) {
    if (r <= a || b <= l) return;

    eval(k, l, r);

    if (a <= l && r <= b) {
      lazy_node[k] = val;
      return;
    }
    update_range(a, b, val, 2*k+1, l, (l+r)/2);
    update_range(a, b, val, 2*k+2, (l+r)/2, r);
  }
};

int main() {
  int N, Q;
  std::cin >> N >> Q;

  std::vector<int> width_valvec(N, N-2);
  std::vector<int> height_valvec(N, N-2);
  LazySegTree<int,int> width(
      [](int a, int b) { return std::min<int>(a, b); },
      1000000000,
      [](int a, int b) { return std::min<int>(a, b); },
      1000000000,
      [](int a, int b) { return std::min<int>(a, b); },
      width_valvec);
  LazySegTree<int,int> height(
      [](int a, int b) { return std::min<int>(a, b); },
      1000000000,
      [](int a, int b) { return std::min<int>(a, b); },
      1000000000,
      [](int a, int b) { return std::min<int>(a, b); },
      width_valvec);

  long long int ngot = 0;
  for (int i = 0; i < Q; i++) {
    int type, x;
    std::cin >> type >> x;
    x--;
    if (type == 1) {
      int heightx = height.op_range(x,x+1);
      //std::cout << heightx << std::endl;
      ngot += heightx;
      width.update_range(1,heightx+1,x-1);
    } else {
      int widthx = width.op_range(x,x+1);
      //std::cout << widthx << std::endl;
      ngot += widthx;
      height.update_range(1,widthx+1,x-1);
    }
  }
  std::cout << ((long long int)N-2)*((long long int)N-2)-ngot << std::endl;
  return 0;
}


Measured memory_bytes: 13392
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	char A,B;
	cin>>A>>B;
	int x=A-'A'+10;
	int y=B-'A'+10;
	if (x>y){
		cout<<">"<<endl;
	}else if (x==y){
		cout<<"="<<endl;
	}else{
		cout<<"<"<<endl;
	}
	return 0;
}

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


int main(){

int n;
cin >> n;
int m = 0;
m = n % 10;

string ans = "hon";

if(m==3) ans = "bon";
if(m == 0 || m == 1 || m == 6 || m == 8) ans = "pon";


cout << ans << endl;

}



Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var S = ReadLine();

        var lSum = 0;
        var rSum = S[1..].Count(c => c == 'E');

        var ans = lSum + rSum;

        for (int i = 1; i < N; i++)
        {
            if(S[i - 1] == 'W')
                lSum++;
            if (S[i] == 'E')
                rSum--;

            ans = Min(ans, lSum + rSum);
        }

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 29596
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
typedef pair<int, int> P;
 
int main(){
  int H, W;
  cin >> H >> W;
  int d[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      d[i][j] = INF;
    }
  }
  char A[H][W];
  queue<P> que;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> A[i][j];
      if(A[i][j] == '#'){
        que.push(P(i,j));
        d[i][j] = 0;
      }
    }
  }
 
  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
 
 
  while(que.size()){
      P p = que.front(); que.pop();
 
      for(int i = 0; i < 4; i++){
          int nx = p.first + dx[i], ny = p.second + dy[i];
 
          if(0 <=nx && nx < H && 0 <=ny && ny < W && d[nx][ny] == INF){
              que.push(P(nx, ny));
              d[nx][ny] = d[p.first][p.second] + 1;
          }
      }
  }
 
  
  int ans1 = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans1 = max(ans1, d[i][j]);
    }
  }
  cout << ans1 << endl;
}

Measured memory_bytes: 13328