akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

const double PI=3.14159265358979;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> x(n),y(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &x[i]);
    }
    for(i=0; i<n; i++) {
        scanf("%d", &y[i]);
    }
    int k;
    double sum[4]={0};
    for(k=1; k<=3; k++) {
        for(i=0; i<n; i++) {        
            sum[k]+=pow(fabs((double)x[i]-y[i]), (double)k);            
        }
        sum[k] = pow(sum[k], (double)1/k);
    }
    double max=-INF;
    for(i=0; i<n; i++) {        
        max=MAX(max,fabs((double)x[i]-y[i]));           
    }
    printf("%.10lf\n%.10lf\n%.10lf\n%.10lf\n", sum[1], sum[2], sum[3], max);

    return 0;
}



Measured memory_bytes: 2940
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;


int main(){
    ll A, B;
    cin >> A >> B;
    if(A % 2 == 0 && B % 2 == 1){
        ll gap = B - A + 1;
        if(gap % 4 == 0) cout << 0 << endl;
        else cout << 1 << endl;
    } else if(A % 2 == 1 && B % 2 == 1){
        ll gap = B - (A + 1) + 1;
        ll C;
        if(gap % 4 == 0) C = 0;
        else C = 1;
        cout << (A ^ C) << endl;
    } else if(A % 2 == 0 && B % 2 == 0){
        ll gap = (B - 1) - A + 1;
        ll C;
        if(gap % 4 == 0) C = 0;
        else C = 1;
        cout << (B ^ C) << endl;
    } else {
        ll gap = (B - 1) - (A + 1) + 1;
        ll C;
        if(gap % 4 == 0) C = 0;
        else C = 1;
        cout << (A ^ B ^ C) << endl;
    }

    
}

Measured memory_bytes: 256
import math

# 最大公約数を求める問題
N, X = map(int, input().split())
x = [int(_) for _ in input().split()]
if N == 1:
    print(abs(x[0]-X))
    exit()

x.sort()
# N > 1と仮定
for i in range(N-1):
    if x[i] < X and x[i+1] > X:
        x = x[:i+1] + [X] + x[i+1:]
        break
    elif x[i] >= X:
        x = [X] + x
        break
    elif x[i+1] <= X:
        x = x + [X]
        break

if len(x) >= 3:
    base = math.gcd(x[1]-x[0], x[2]-x[1])
    for i in range(2, N):
        diff = x[i+1] - x[i]
        base = math.gcd(base, diff)
    print(base)
else:
    print(x[1] - x[0])


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

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n){
        cin >> v.at(i);
    }

    vector<vector<ll>> dp(n+1,vector<ll>(2));
    dp.at(0).at(1) = -1e10;
    rep(i,n-1){
        dp.at(i+1).at(0) = max(dp.at(i).at(0) + v.at(i), dp.at(i).at(1) - v.at(i));
        dp.at(i+1).at(1) = max(dp.at(i).at(0) - v.at(i), dp.at(i).at(1) + v.at(i));
        // cout << i << " " << dp.at(i+1).at(0) << " " << dp.at(i+1).at(1) << endl;
    }
    dp.at(n).at(0) = dp.at(n-1).at(0) + v.at(n-1);
    dp.at(n).at(1) = dp.at(n-1).at(1) - v.at(n-1);
    // cout << n-1 << " " << dp.at(n).at(0) << " " << dp.at(n).at(1) << endl;
    ll res = max(dp.at(n).at(0),dp.at(n).at(1));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	int ls=s.size(),lt=t.size();
	vector<vector<int> >dp((ls+1),vector<int>(lt+1));
	int i,j;
	for(i=0;i<=ls;++i) for(j=0;j<=lt;++j){
		if(!i or !j) dp[i][j]=0;
		else if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
		else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	} 
	string ans="";
	i=ls,j=lt;
	while(i and j){
		if(s[i-1]==t[j-1]){
			ans=s[i-1]+ans;
			--i,--j;
		}else if(dp[i-1][j]>+dp[i][j-1]) --i;
		else --j;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35584
//in the name of Allah
#include <bits/stdc++.h>
using namespace std ;
#define F first
#define S second
typedef long long ll ;
const ll N = 100001 ;
ll n , m , ans = 0 , x =0;
char a[1002][10002] ;
vector<pair<ll,ll> > v1 , v2;
int main()
{
std::ios::sync_with_stdio(0) ;
cin.tie(0) ;
cout.tie(0);
cin >> n >> m ;
for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j< m ; j ++){
        cin >> a[i][j] ;
        if(a[i][j] == '#'){
            pair<ll,ll> p;
            p.F = i ;
            p.S= j ;
            v1.push_back(p) ;
            ans ++ ;
        }
    }
}
while(ans < n*m){
    for(int i = 0 ; i< v1.size() ; i ++){
        ll x = v1[i].F , y= v1[i].S ;
        if(x>0){
            if(a[x-1][y] != '#'){
                a[x-1][y] = '#' ;
                ans ++ ;
                pair<ll,ll> p ;
                p.F = x-1 ;
                p.S = y ;
                v2.push_back(p) ;
            }
        }
         if(x<n-1){
            if(a[x+1][y] != '#'){
                a[x+1][y] = '#' ;
                ans ++ ;
                pair<ll,ll> p ;
                p.F = x+1 ;
                p.S = y ;
                v2.push_back(p) ;
            }
         }
         if(y>0){
            if(a[x][y-1] != '#'){
                a[x][y-1] = '#' ;
                ans ++ ;
                pair<ll,ll> p ;
                p.F = x ;
                p.S = y-1 ;
                v2.push_back(p) ;
            }
         }
         if(y<m-1){
            if(a[x][y+1] != '#'){
                a[x][y+1] = '#' ;
                ans ++ ;
                pair<ll,ll> p ;
                p.F = x ;
                p.S = y+1 ;
                v2.push_back(p) ;
            }
         }
    }
    v1.clear() ;
    v1 = v2 ;
    v2.clear() ;
    x ++ ;
}
cout << x ;
	return 0;
}


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

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> xs(n), ys(m);
    for (int i=0; i<n; ++i) cin >> xs[i];
    for (int i=0; i<m; ++i) cin >> ys[i];
    sort(xs.begin(), xs.end(), greater<int>());
    sort(ys.begin(), ys.end());
    bool ans = false;
    for (int i=xs[0]+1; i<=ys[0]; ++i) {
        if (x < i && i <= y) ans = true;
    }
    cout << (ans ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
import collections
N = int(input())

num = list(map(int,input().split()))
c = collections.Counter(num)
if len(c) == 3:
  if c.most_common()[0][1] == c.most_common()[1][1]:
    if (c.most_common()[0][0])^(c.most_common()[1][0]) == c.most_common()[2][0]:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
elif len(c) == 2:
  if c.most_common()[0][1] == 2*c.most_common()[1][1]:
    if c.most_common()[1][0] == 0:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
elif len(c) == 1:
  if c.most_common()[0][0] == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')


Measured memory_bytes: 14468
n=int(input())
from collections import defaultdict
import math
a=list(map(int,input().split()))
d=defaultdict(int)
for m in a:
  d[m]+=1
sm=0
for m in d:
  if d[m]>1:
    sm+=d[m]*(d[m]-1)//2
for m in a:
  if d[m]>2:
    print(sm-d[m]+1)
  elif d[m]==2:
    print(sm-1)
  else:
    print(sm)

  



Measured memory_bytes: 34188
#include<bits/stdc++.h>
using namespace std;
int n,k,a;
char c;
string s="";
bool u;
int main(){
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>c;
		s+=c;
	}
	for(int i=n;;i++){
		a=i;u=1;
		while(a>0){
			if(s.find(a%10+'0')<10){
				u=0;
				break;
			}
			a/=10;
		}
		if(u){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
n=int(input())
if n==1:
  print("1")
else:
  import numpy as np
  
  def seachPrimeNum(N):
      max = int(np.sqrt(N))
      seachList = [i for i in range(2,N+1)]
      primeNum = []
      while seachList[0] <= max:
          primeNum.append(seachList[0])
          tmp = seachList[0]
          seachList = [i for i in seachList if i % tmp != 0]
      primeNum.extend(seachList)
      return primeNum
    
  f=len(seachPrimeNum(n))
  g=seachPrimeNum(n)
  c=1
  
  for j in range(f):
    e=g[j]
    a=0
    b=n
    h=0
    while b>=e:
      b=b//e
      h=h+b
      a=a+1
    c=c*(h+1)
  print(c%(10**9+7))

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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }
  vector<vector<int>> cnt(H, vector<int>(W, 0));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      for(int k = -1; k <= 1; k++){
        for(int l = -1; l <= 1; l++){
          int x = j + l, y = i + k;
          if(0 <= i + k && i + k < H && 0 <= j + l && j + l < W){
            if(S[y][x] == '#'){
              cnt[i][j]++;
            }
          }
        }
      }
    }
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '.')cout << cnt[i][j];
      else cout << "#";
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
from copy import deepcopy
EMP = -1            # 未チェック
BLOCK = -2          # 壁

input_data = input().split()
h, w = map(int, input_data)

# 迷路情報
maze_map = [[EMP for i in range(w)] for j in range(h)]

# 座標リスト(上、左、右、下)
pos_list = [[-1,0], [0,-1], [0,1], [1,0]]

# 迷路取得
for i in range(h):
    input_data = input()
    char_data = list(input_data)

    for j in range(len(char_data)):
        # 壁は-2
        if(char_data[j] == "#"):
            maze_map[i][j] = BLOCK

# 最大値取得
max_mass = 0

# 探索
for i in range(h):
    for j in range(w):

        # 迷路、キューを初期化
        tmp_maze_map = deepcopy(maze_map)
        queue_list = []

        # 自身の位置を開始位置とする(壁の時は見ない)
        if(tmp_maze_map[i][j] == BLOCK):
            continue
        tmp_maze_map[i][j] = 0

        # キューに自身を入れる
        queue_list.append([i,j])

        while(len(queue_list) > 0):
            get_x = queue_list[0][0]
            get_y = queue_list[0][1]

            # 隣のチェック
            for k in pos_list:
                rin_x = get_x + k[0]
                rin_y = get_y + k[1]
            
                # 自身が壁
                if(tmp_maze_map[get_x][get_y] == BLOCK):
                    continue
                # 隣が範囲を超える
                if((rin_x < 0) or (rin_x >= h) or (rin_y < 0) or (rin_y >= w)):
                    continue
                # 隣が空でない
                if(tmp_maze_map[rin_x][rin_y] != EMP):
                    continue
                # 距離計算
                tmp_maze_map[rin_x][rin_y] = tmp_maze_map[get_x][get_y] + 1
                queue_list.append([rin_x,rin_y])            

            # チェックしたマスを取り除く
            queue_list.pop(0)

        # 最大値を取得
        for k in tmp_maze_map:
            t_sum_list = deepcopy(k)
            t_sum_list += [max_mass]
            max_mass = max(t_sum_list)
            t_sum_list.clear()
        
        # 迷路リセット
        tmp_maze_map.clear()

print(max_mass)

Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

typedef long long LL;

typedef unsigned long long uLL;

#define REP(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define DREP(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define EREP(i, a) for(register int i = (be[a]); i != -1; i = nxt[i])
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mem(a, b) memset((a), b, sizeof(a))

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template <class T>
T read(T sum = 0, T fg = 0)
{
	char c = getchar();
	while(c < '0' || c > '9') { fg |= c == '-'; c = getchar(); }
	while(c >= '0' && c <= '9') { sum = sum * 10 + c - '0'; c = getchar(); }
	return fg ? -sum : sum;
}

const int inf = 1e9;

const LL INF = 1e17;

const int Size = 100000;

int main()
{
	string s;
	cin >> s;
	int len = s.length();
	string ans = s.substr(0, len - 8);
	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);
		        String S = sc.next();
		        long res = 0;
		        int n = S.length()-1;


		        for(int i = 0;i<Math.pow(2, n);i++) {//2^n通りの全探索

		        	StringBuilder sb = new StringBuilder(S);

		        	for(int j = n-1;j>=0;j--) {
		        		if((1&i>>j)==1) {
		        			sb.insert(j+1, "+");
		        		}
		        	}

		        	String[] s = sb.toString().split("\\+",0);
		        	for(int k = 0;k<s.length;k++) {
		        		res+=Long.parseLong(s[k]);
		        	}

		        }

		        System.out.println(res);
	}

}

Measured memory_bytes: 22100
import Control.Applicative((<$>))
import Control.Monad
import Data.Map ((!))
import qualified Data.Map as M
-- import Data.IntMap ((!))
-- import qualified Data.IntMap as M
import qualified Data.List as L
import Data.Maybe (catMaybes)
-- import qualified Data.Char as C
-- import qualified Data.IntSet as I
import Data.List (sort)
import Debug.Trace
--------------------------------------------
readInt    = read :: String -> Int
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
int2bin 0 =  []
int2bin n =  n `mod` 2 : int2bin (n `div` 2)
----------------------------------------------

search = aux 0
  where
    aux c m (a:as)
      | c == m    = (a, head as)
      | otherwise = aux (c+1) m as

main :: IO ()
main = do
  n  <- getInt
  t_xs <- getIntList
  let
    xs = sort t_xs
    (n1, n2) = search (n `div` 2 - 1) xs
  forM_ t_xs $ \x ->
    print $ if x <= n1 then n2 else n1

Measured memory_bytes: 105852
s = input()
a = 0
ans = 0
b = 0
d = [0]
e = []
now = 0

for i in range(len(s)):
    if s[i] == '<':
        
        if a != 0:
            if a > now:
                ans = ans - d[-1] + a
                
            for j in range(a):
                ans = ans + j
                d.append(a - j)
                e.append(">")
            now = 0
            a = 0
        
        ans = ans + now + 1
        now = now + 1
        d.append(now)
        
    else:
        a = a + 1
        b = 0
    
if a != 0:
    if a > now:
        ans = ans - d[-1] + a
                
    for j in range(a):
        ans = ans + j
        d.append(a - j)
        e.append(">")
    
print(ans)

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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

int main() {
    vll nums(2);
    int k;
    cin >> nums[0] >> nums[1] >> k;
    int index;
    for (int i = 0; i < k; ++i) {
        index = i & 1;
        if (nums[index] & 1) --nums[index];
        nums[index] >>= 1;
        nums[!index] += nums[index];
    }
    cout << nums[0] << " " << nums[1] << endl;
    return 0;

}

Measured memory_bytes: 256
N = int(input())
S = input()
a = []
first = 0
for k in range(1, N):
  if S[k] == 'E':
    first += 1

a.append(first)
for k in range(1, N):
  a.append(a[-1] + (S[k-1] == 'W') - (S[k] == 'E'))
print(min(a))

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

int main()
{
    bool fx = false;
    bool fy = false;
    string ans = "No";
    int x, y;
    cin >> x >> y;
    vector<int> a = {1, 3, 5, 7, 8, 10, 12};
    vector<int> b = {4, 6, 9, 11};
    if (x == 2 && y == 2)
    {
        ans = "Yes";
    }
    else
    {
        REP(i, 7)
        {
            if (x == a.at(i))
                fx = true;
            if (y == a.at(i))
                fy = true;
        }
        if (fx && fy)
        {
            ans = "Yes";
        }
        else
        {
            fx = false;
            fy = false;
            REP(i, 4)
            {
                if (x == b.at(i))
                    fx = true;
                if (y == b.at(i))
                    fy = true;
            }
            if (fx && fy)
            {
                ans = "Yes";
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

using ll = long long int;
using ld = long double;
using pii = pair<int,int>;

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()

int main(){
  string s;cin >> s;
  int n=s.size();
  int i=0,ans=0;
  while(i<n-i-1){
    if(s[i]!=s[n-1-i])ans++;
    i++;}
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
from numba import jit

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	h, w, k = LI()
	grid = GRIDfromString(h,w)
	ans = 0
	cnt = 0
	for i in range(h):
		for j in range(w):
			h_comb = list(itertools.combinations(list(range(h)),i))
			w_comb = list(itertools.combinations(list(range(w)),j))
			if i == 0 and j == 0:
				if np.count_nonzero(grid == b'#') == k:
					ans += 1
			elif i == 0 and j > 0:
				for w_omits in w_comb:
					if np.count_nonzero(np.delete(grid,list(w_omits),1) == b'#') == k:
						ans += 1
			elif i > 0 and j == 0:
				for h_omits in h_comb:
					if np.count_nonzero(np.delete(grid,list(h_omits),0) == b'#') == k:
						ans += 1
			else:
				for h_omits in h_comb:
					grid_tmp = np.delete(grid,list(h_omits),0)
					for w_omits in w_comb:
						if np.count_nonzero(np.delete(grid_tmp,list(w_omits),1) == b'#') == k:
							ans += 1
	print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 91732
import sys
n = int(sys.stdin.readline().strip())

cnt_flag = 0
res = False
for idx in range(n):
    this_time_vec = sys.stdin.readline().strip().split(' ')
    d_1 = int(this_time_vec[0])
    d_2 = int(this_time_vec[1])
    if d_1 == d_2:
        if cnt_flag > 0:
            cnt_flag = cnt_flag + 1
            if cnt_flag >= 3:
                res = True
                break
        else:
            cnt_flag = 1
    else:
        cnt_flag = 0
    
if res == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9192
#include <assert.h>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <limits.h>
#include <mutex>
#include <thread>
#include <vector>

int main(){
  int N;
  scanf("%d",&N);
  std::vector<int > P(N);
  std::vector<int > Q(N);
  int array[N], array2[N];
  for (int i=0; i<N; i++){
    scanf("%d",&P[i]);
    P[i]--;
    array[i] = i;
    array2[i] = i;
  }
  for (int i=0; i<N; i++){
    scanf("%d",&Q[i]);
    Q[i]--;
  }
  
  int a=0;
  int count=0;
  do {
    for (int i = 0; i < N; i++) {
      if (P[i]!=array[i]){
        break;
      }
      if (i==N-1){
        a = count;
        break;
      }
    }
    count++;
    if (a!=0){
      break;
    }
  }while (std::next_permutation(array, array + N));

  int b=0;
  count=0;
  do {
    for (int i = 0; i < N; i++) {
      if (Q[i]!=array2[i]){
        break;
      }
      if (i==N-1){
        b = count;
        break;
      }
    }
    count++;
    if (b!=0){
      break;
    }
  }while (std::next_permutation(array2, array2 + N));

  std::cout<<abs(b-a)<<std::endl;
  return 0;
}


Measured memory_bytes: 888
#include<limits>
using ll=long long;constexpr int INF=std::numeric_limits<int>::max()/2;constexpr ll LNF=std::numeric_limits<ll>::max()/2;constexpr double EPS=1e-8;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};
#ifdef PA_DEBUG
#define PD(stmt)stmt
#else
#define PD(stmt)
#endif
#include<iostream>
#include<vector>
namespace pcl{namespace utility{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}}using namespace pcl::utility;
#include<bits/stdc++.h>
using namespace std;int main(){int N;cin>>N;if(N>=1000)cout<<"ABD"<<endl;else cout<<"ABC"<<endl;}

Measured memory_bytes: 256
//smit.mangukiys
					#include<bits/stdc++.h>
                    #include <set>
					#include <ext/pb_ds/assoc_container.hpp>
					#include <ext/pb_ds/tree_policy.hpp>
					using namespace __gnu_pbds;
					#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
					using namespace std;
                    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
                    #define pb push_back
                    #define ff first
                    #define ss second
                    #define sz size()
                    #define mp make_pair
                    #define int long long int
                    #define double long double
                    #define bp __builtin_popcountll
                    #define FOR(i,a,b) for(int i=a;i<b;i++)
                    #define ROR(i,a,b) for(int i=a;i>=b;i--)
                    const int M=1e9+7;
                    const int N=1e6+5;
                    const int inf=1e18;
                    string s;
                    int n;
                    int dp[N][2];
                    int solve(int idx,int vaddi)
                    {
                    	if(idx==0)
                    	{
                    		if(vaddi==1)
                    		return 1;
                    		return 0;
                    	}
                    	int &ans=dp[idx][vaddi];
                    	if(ans!=-1)
                    	return ans;
                    	ans=0;
                    	char pp;
                    	if(vaddi==1)
                    	{
                    		pp=s[idx]+1;
                    		if(s[idx]+1>'9')
                    		ans=solve(idx-1,1);
                    		else
                    		ans=min((pp-'0')+solve(idx-1,0),(10 +'0'-pp)+solve(idx-1,1));

                    	}
						else
						ans=min((s[idx]-'0')+solve(idx-1,0),(10 +'0'-s[idx])+solve(idx-1,1));
                    	return ans;
                    }
                    int32_t main()
                    {
                		FAST
                		cin>>s;
                		s='0'+s;
                		n=s.size();
                		// cout<<s;
                		memset(dp,-1,sizeof(dp));
                		cout<<(solve(n,0)+48);
                    }

Measured memory_bytes: 63944
using namespace std;

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

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> x(N),y;
    for (int i = 0; i < N; i++){
        cin >> x[i];
    }
    copy(all(x),back_inserter(y));
    sort(all(y));
    int mid = y[N/2];
    for(int i = 0; i < N; i++){
        if (x[i] < mid){
            cout << mid << endl;
        } else {
            cout << y[N/2-1] << endl;
        }
    }
            


    return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(long long A, long double B){
    ll Bint = (ll)round(B*100);
    ll ans = A*Bint;
    cout<<ans/100<<endl;
}
int main(){
    long long A;
    scanf("%lld",&A);
    long double B;
    scanf("%Lf",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.1415926536
struct Point
{
    int x;
    int y;
};
inline double dist(Point a, Point b)
{
    return sqrt( pow(a.x - b.x , 2) + pow(a.y - b.y, 2) );
}
Point point[200005];
Point st[200005];
void getExtremePoint(int n)///at index 0
{
    int pos = 0;
    for(int i=1; i<n; i++){
        if(point[i].y < point[pos].y || (point[i].y == point[pos].y && point[i].x < point[pos].x))
            pos = i;
    }
    swap(point[0], point[pos]);
}
inline int triArea(Point p1, Point p2, Point p3)
{
    ll area = 1LL*p1.x*(p2.y - p3.y) + 1LL*p2.x*(p3.y - p1.y) + 1LL*p3.x*(p1.y - p2.y);
    if(area==0) return area;
    else return area/llabs(area);
}
inline bool comp(Point p1, Point p2)
{
    int tri = triArea(point[0],p1,p2);
    if(tri<0) return false;
    if(tri==0 && dist(point[0], p1) > dist(point[0], p2)) return false;
    return true;
}
bool comp2(Point p1, Point p2)
{
	if(p1.x==p2.x) 
		return p1.y<p2.y;
	return p1.x<p2.x;
}
int id;
void genConvexPoints(int n)
{
    getExtremePoint(n);
    sort(point+1, point+n, comp);
    id = 0;
    for(int i=0; i<3 && i<n; i++)
        st[id++] = point[i];
    for(int i = 3; i<n; i++){
        while(triArea(st[id-2], st[id-1], point[i]) <= 0 && id>=2)
            id--;
        st[id++] = point[i];
    }
}
int main()
{
    int tc,cs=1,n,d;
    tc = 1;
    while(tc--){
    	set< pair<int, int> >mp;
        scanf("%d",&n);
        int idx = 0;
        for(int i=0; i<n; i++){
            scanf("%d%d",&point[i].x,&point[i].y);
            mp.insert( make_pair(point[i].x,point[i].y));
            if(mp.size() > idx )
            	point[idx++] = point[i];
        }
        n = idx;
        genConvexPoints(n);
      	assert(id<=50);
        int ans = 0;
        for(int i=0; i<id; i++){
        	for(int j=i+1; j<id; j++){
        		ans = max(ans, abs(st[i].x-st[j].x) + abs(st[i].y - st[j].y  ));
        	}
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 14676
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	//freopen("in.txt", "r", stdin);
	ll k;
	cin >> k;
	int n = 50;
	vl ret(n);
	rep(i,0,n) {
		ret[i] = i;
	}
	ll x = k / n;
	ll y = k % n;
	rep(i,0,n) {
		ret[i] += x;
	}
	rep(i,0,y) {
		ret[i] += (ll)n;
		ret[i] -= y-1;
	}
	rep(i,y,n) {
		ret[i] -= y;
	}
	cout << n << '\n';
	rep(i,0,n) {
		cout << ret[i] << ' ';
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string tmp,ta,tb;
  ll a,b,num;
  cin >> a >> b;
  ta = to_string(a);
  tb = to_string(b);
  tmp = ta+tb;
  num = stoi(tmp);
  for(ll i=1;i*i<=num;i++){
    if(i*i==num){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
}


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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  string s;
  cin >> s;
  int zeroNum,oneNum,ii;
  zeroNum = oneNum = 0;
  for(ii=0;ii<s.length();ii++){
    if(s[ii] == '0' ){
      zeroNum ++;
    }
    else{
      oneNum ++;
    }
  }

  if(zeroNum < oneNum){
    cout << zeroNum * 2 << endl;
  }
  else{
    cout << oneNum * 2 << endl;
  }
  return 0;
}


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

int main () {
    int x;
    cin >> x;
    if(x % 1000 == 0)
        cout << 0;
    else {
        int y = x / 1000 + 1;
        cout <<  - x + y * 1000;
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a,odd = 0; 
    REP(i,n){
        cin >> a;
        if(a % 2 == 1) odd++;
    }
    if(odd % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#define ll long long

using namespace std;

int main(void){
    ll a, b, n;
    cin >> a >> b >> n;
    ll v = a*a*b;
    double pi = 3.1415926535;
    if(n<=v/2){
        double x = double(2*n)/double(a*b);
        double ATAN = atan(x/double(b));
        cout << fixed << setprecision(15) << 90-ATAN*180/pi << endl;;
    }
    else if(n>v/2){
        double x = (2*double(n))/double(a*a) - b;
        double ATAN = atan(double(a)/double(b-x));
        cout << fixed << setprecision(15) << 90-ATAN*180/pi << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string n; cin >> n;
    ll m = stoll(n);
    ll sum = 0;
    for(int i = 0; i < n.size(); i++)
    {
        sum += n[i] - '0';
    }
    if(m % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 256
s=input()
n=len(s)
t=input()
m=len(t)
data=[]
for i in range(n-m+1):
    ans=""
    for j in range(i):
        if s[j]=="?":
            ans+="a"
        else:
            ans+=s[j]
    for j in range(m):
        if s[i+j]=="?":
            ans+=t[j]
        elif s[i+j]==t[j]:
            ans+=t[j]
        else:
            break
    else:
        for j in range(n-i-m):
            if s[m+i+j]=="?":
                ans+="a"
            else:
                ans+=s[m+i+j]
        data.append(ans)
data.sort()
if data:
    print(data[0])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n,i;

int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%d%d",&n,&i)!=EOF)
    {
        printf("%d\n",n-i+1);
    }
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.exitsurvey2", "r", stdin );
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	long long total = 0LL;

	int i;
	for (i = 0; i < n; ++i){
		int money = 0;
		getline (cin, str );
		stringstream ss(str);
		ss >> money;

		total += (long long)money;
	} // end loop
	
	long long res = total/n;
	cout << res << endl;	
		
	return 0;
}

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

#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define endl "\n"

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep(i,n)        for(int i = 0; i < n; i++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
     IOS
     ll t,n,i;
     string s;
     cin>>s;
     int cnt=0,ans=0;
     rep(i,s.size())
     {
          if(s[i]=='R')
               cnt++;
          else
          {
               ans = max(cnt,ans);
               cnt=0;
          }
     }
     ans = max(cnt,ans);
     cout<<ans;

     return 0;
}


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

int main() {
  string s;
  cin>>s;
  string kotae="aaa";
  rep(i,3){
    kotae.at(i)=s.at(i);
  }
  cout<<kotae;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(){
    int ans=0;
    int a,b,c;
    cin >> a >> b >> c;
    int d=b/a;
    ans=min(d,c);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    Set<Integer> set = new HashSet<>();
    
    // i = 1
    int prev = s;
    set.add(s);

    int i = 2;
    while (true) {
      int v = prev%2 == 0 ? prev/2 : 3*prev+1;
      if (set.contains(v)) {
        System.out.println(i);
        return;
      }
      set.add(v);
      prev = v;
      i++;
    }
  }
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s=="SUN") cout<<7;
	if(s=="MON") cout<<6;
	if(s=="TUE") cout<<5;
	if(s=="WED") cout<<4;
	if(s=="THU") cout<<3;
	if(s=="FRI") cout<<2;
	if(s=="SAT") cout<<1;
	return 0;
}

Measured memory_bytes: 764
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            x = int.Parse(Console.ReadLine());
            if (x == 7 || x == 5 || x == 3)
            {
                Console.WriteLine("YES\n");
            }
            else
            {
                Console.WriteLine("NO\n");
            }

        }
    }
}


Measured memory_bytes: 11092
a,b,k = list(map(int, input().split()))
ans = []
for i in range(k):
    n = a + i
    if n > b:
        break
    ans.append(n)

st = b - k + 1
st = max(st, ans[-1]+1)
for i in range(st, b+1):
    ans.append(i)

print(*ans, sep='\n')

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

int main(){
  string S;
  cin >> S;
  if (S == "Sunny") cout << "Cloudy" << endl;
  else if (S == "Cloudy") cout <<"Rainy"<<endl;
  else if (S=="Rainy") cout << "Sunny" << endl;




  return 0;
}

Measured memory_bytes: 256
#include <iostream>

inline int gcd(int a, int b){
  if(b<a) std::swap(a, b);
  int r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}

inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int cnt[1000001];

int main(){
  int n = read();
  int o = 0, g;
  for(int i=0;i<n;i++){
    int num = read();
    if(num==1) o++;
    if(i==0) g = num;
    else g = gcd(g, num);
    cnt[num]++;
  }

  if(n - o > 80000){
    if(g==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
  }

  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    int S = 0;
    for(int j=i;j<=1000000;j+=i) S += cnt[j];
    max_S = std::max(max_S, S);
  }
  if(max_S<2) printf("pairwise coprime\n");
  else if(max_S != n) printf("setwise coprime\n");
  else printf("not coprime\n");
}


Measured memory_bytes: 7548
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- Sat Apr  4 17:53:32 2020

*/ 
#include<bits/stdc++.h>
using namespace std;


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<< " "<<c<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




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

int main(){
  int n,m;
  string s;
  map<string,bool> id;
  bool open = false;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    id[s] = true;
  }

  cin >> m;
  for(int i=0;i<m;i++){
    cin >> s;
    if(id[s]){
      if(open)cout << "Closed by " << s << endl;
      else cout << "Opened by " << s << endl;
      open = !open;
    }else{
      cout << "Unknown " << s << endl;
    }
  }
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}

int main() {
int N;
cin>>N;
vector<pair<ll,ll>> v;
for(int i=0;i<N;i++) {
    ll X,L;
    cin>>X>>L;
    v.push_back({X+L,X-L});
}
sort(all(v));
int maxv = 1000000000;
int mini = -maxv, cnt = 0;
for(auto x: v) {
    if(mini<=x.second) {
        mini = x.first;
        cnt++;
    }
}
cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 3444
x = 0
cli = [[0] * 2 for i in range(1001)]

while True:
    try:
        c, d = map(int, input().split(","))
    except:
        if x == 1:
            break
        x += 1
        continue
    cli[c][x] += 1

for i in range(1,1001):
    if(cli[i][0] and cli[i][1]):
        print(i, cli[i][0] + cli[i][1])

Measured memory_bytes: 7724
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T> // key
struct RadixHeap{
	vector<pair<int, T>> v[31]; //max<2^30
	int last;
	int size;
	inline int bsr(int x){
		if(x==0) return -1;
		else return 31-__builtin_clz(x);
	}
	RadixHeap():last(0), size(0){}
	bool empty(){
		return size==0;
	}
	void push(int val, T key){
		size++;
		v[bsr(val^last)+1].push_back({val, key});
	}
	pair<int, T> pop(){
		size--;
		if(!v[0].empty()){
			auto ret=v[0].back();
			v[0].pop_back();
			return ret;
		}
		int k=1;
		while(v[k].empty()) k++;
		int minval=v[k][0].first;
		T minkey=v[k][0].second;
		for(auto p:v[k]){
			if(p.first<minval){
				minval=p.first;
				minkey=p.second;
			}
		}
		last=minval;
		bool myon=1;
		for(auto p:v[k]){
			if(myon && p.first==minval && p.second==minkey){
				myon=0;
				continue;
			}
			v[bsr(p.first^last)+1].push_back(p);
		}
		v[k].clear();
		return make_pair(minval, minkey);
	}
};
int main()
{
	int n, m, s;
	scanf("%d %d %d", &n, &m, &s);
	vector<vector<P>> g(n);
	for(int i=0; i<m; i++){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		g[a].push_back({b, c});
	}
	const int INF=1e9+7;
	RadixHeap<int> que;
	vector<int> d(n, INF);
	d[s]=0;
	que.push(0, s);
	while(!que.empty()){
		auto p=que.pop();
		int x=p.second;
		if(d[x]<p.first) continue;
		for(auto q:g[x]){
			int y=q.first;
			if(d[y]>d[x]+q.second){
				d[y]=d[x]+q.second;
				que.push(d[y], y);
			}
		}
	}
	for(int i=0; i<n; i++){
		if(d[i]==INF) printf("INF\n");
		else printf("%d\n", d[i]);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}


int x , y , a , b ,c;
int p[maxn] , q[maxn] , r[maxn];
vector < ll > vec;
ll ans = 0;

int main(){
    migmig
    cin >> x >> y >> a >> b >> c;
    for(int i = 0 ; i < a ; i ++){
        cin >> p[i];
    }
    sort(p , p + a);
    reverse(p , p + a);
    for(int i = 0 ; i < b ; i ++){
        cin >> q[i];
    }
    sort(q , q + b);
    reverse(q , q + b);
    for(int i = 0 ; i < c ; i ++){
        cin >> r[i];
    }
    sort(r , r + c);
    reverse(r , r + c);
    for(int i = 0 ; i < x; i ++ ){
        vec.pb(p[i]);
    }
    for(int i = 0 ; i < y ; i ++){
        vec.pb(q[i]);
    }
    for(int i = 0 ; i < c ; i ++){
        vec.pb(r[i]);
    }
    sort(vec.begin() , vec.end());
    reverse(vec.begin() , vec.end());
    for(int i = 0 ; i < x+y ; i ++){
        ans+=vec[i];
    }
    cout << ans;
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


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

int main(void){
    int num1;
    int num2;
    char text[2][20];
    int i, j, k ,l;
    l = scanf("%d%d", &num1, &num2);
    if(l < 0){
        fprintf(stderr, "error");
    }
    sprintf(text[0], "%d", num1);
    sprintf(text[1], "%d", num2);
    strcat(text[0], text[1]);
    i = atoi(text[0]);
    for(j = 1, k = 0; k < 100000; j++){
        k = j * j;
        if(i == k){
            printf("Yes");
            exit(0);
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
using namespace std;
int main()
{
    int n,at;
    
    cin>>n;
    vector<int> a(n+1);
    for(int i=0;i<n+1;i++){a[i]=0;}
    
    for(int i=1;i<n;i++){
        cin>>at;
        a[at]++;
        
    }
    
    for(int i=1;i<n+1;i++){
        cout<<a[i]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 4048
package main

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

func main() {
	r := nextInt()
	D := nextInt()
	x := nextInt()
	for i := 1; i <= 10; i++ {
		x = r*x - D
		fmt.Println(x)
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640