akhauriyash/Code-Regression huggingface dataset:
import itertools

n, m = map(int, input().split())

path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

ans = 0

for i in itertools.permutations(range(n), n):#N!
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j + 1]]:
                break

print(ans)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll n,m,k,l,g,i,h,w,a1,a2,a3,a4,a5,a6,a,b,c;
    	cin>>n>>a>>b;
    	if(a+b==0)
    	cout<<0;
    	else
    	{
    		m=(n/(a+b))*a;
    		l=n%(a+b);
    		m+=min(a,l);
    		cout<<m;
		}
    	
    	
    	
    	
	}
	return 0;
}

Measured memory_bytes: 256
// c++ cpp.cpp -o cpp.exe -std=c++14

#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)

struct hw
{
    int h, w;
};

hw start;
int h, w, n;
vector<string> maze;

int cnt = 0;
vector<vector<int>> visited;

int bfs(int target)
{
    visited.resize(h);
    rep(j, h)
    {
        visited[j].resize(w);
        rep(i, w)
        {
            visited[j][i] = -1;
        }
    }
    queue<hw> q;
    q.push(start);
    visited[start.h][start.w] = 0;

    while (!q.empty())
    {
        hw now = q.front();
        q.pop();
        if (maze[now.h][now.w] == target + '0')
        {
            start = now;
            return visited[now.h][now.w];
        }
        hw nxt;
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if ((i == 0 && j == 0) || (i != 0 && j != 0))
                {
                    continue;
                }
                nxt = {now.h + i, now.w + j};
                if (nxt.h < 0 || nxt.h == h || nxt.w < 0 || nxt.w == w)
                {
                    continue;
                }
                else if (maze[nxt.h][nxt.w] == 'X')
                {
                    continue;
                }
                else if (visited[nxt.h][nxt.w] == -1)
                {
                    q.push(nxt);
                    visited[nxt.h][nxt.w] = visited[now.h][now.w] + 1;
                }
            }
        }
    }
}

int main()
{
    cin >> h >> w >> n;
    maze.resize(h);
    rep(i, h)
    {
        cin >> maze[i];
    }

    rep(j, h)
    {
        rep(i, w)
        {
            if (maze[j][i] == 'S')
            {
                start = {j, i};
            }
        }
    }
    rep(i, n)
    {
        cnt += bfs(i + 1);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 7848
N = int(input())
Norigin = N
alphabet = "abcdefghijklmnopqrstuvwxyz"
j = 0
start = 0
end = 0
while 1:
    if N <= 0:
        end = start + 26**(j)
        break
    else:
        start += 26**j
        j += 1
        N -= 26**j
ans = []
Norigin = Norigin-start
for i in range(j):
    ans.append(alphabet[Norigin % 26])
    Norigin = Norigin//26
ans.reverse()
print("".join(ans))


Measured memory_bytes: 61856
N,M = map(int,input().split())
students = [list(map(int,input().split()))for i in range(N)]
checkPoints = [list(map(int,input().split()))for i in range(M)]

for i in range(N):
    idx = 1
    mindis = abs(students[i][0]-checkPoints[0][0])+ abs(students[i][1]-checkPoints[0][1])
    sx,sy = students[i]
    for j in range(1,M):
        cx,cy = checkPoints[j]
        distance = abs(sx-cx)+ abs(sy-cy)
        if mindis > distance:
            idx = j+1
            mindis = distance
    print(idx)



Measured memory_bytes: 66220
# include<cstdio>
# include<cstring>
using namespace std;
char map[52][52],ans[52][52];
int dir[8][2]={{0,-1},{0,1},{-1,0},{1,0},{-1,1},{1,1},{1,-1},{-1,-1}};
int n,m;
void work(int x,int y)
{
	int count=0;
	for(int i=0;i<8;i++)
	{
		int newx=x+dir[i][0];
		int newy=y+dir[i][1];
		if(newx<1 || newx>n || newy<1 || newy>m)continue;
		if(map[newx][newy]=='#')count++;
	}
	ans[x][y]=count+'0';
	//printf("%d %d %d\n",x,y,count);
}
char get_char()
{
	char c=getchar();
	while(c==' ' || c=='\n')c=getchar();
	return c;
}
int main()//AT3595
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			map[i][j]=get_char();
	for(int i=1;i<=n;i++)	
		for(int j=1;j<=m;j++)
		{
			if(map[i][j]=='.')work(i,j);
			else ans[i][j]='#';
		}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			putchar(ans[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>  
#include <cctype>


using namespace std;


int main() {

	string s, t, r;

	cin >> s >> t >> r;
	
	transform(s.begin(), s.end(), s.begin(), ::toupper);
	transform(t.begin(), t.end(), t.begin(), ::toupper);
	transform(r.begin(), r.end(), r.begin(), ::toupper);

	cout << s[0] << t[0] << r[0] << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 1e5 + 5;
vector<pii> a[N];
int visited[N];
int mincolor;
int color[N];

void dfs(int cur, int col)
{
	vector<int> used(mincolor + 1);
	int st = 1;
	for (auto branch : a[cur]) {
		if (!visited[branch.first]) {
			visited[branch.first] = 1;
			for (int i = st; i <= mincolor; i++) {
				if (!used[i] && i != col) {
					used[i] = 1;
					color[branch.second] = i;
					st = i + 1;
					break;
				}
			}
			dfs(branch.first, color[branch.second]);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		a[u].push_back({v, i});
		a[v].push_back({u, i});
	}
	mincolor = 1;
	for (int i = 1; i <= n; i++) {
		mincolor = max(mincolor, (int) a[i].size());
	}
	cout << mincolor << "\n";
	int root;
	for (int i = 1; i <= n; i++) {
		if (mincolor == a[i].size()) {
			root = i;
			break;
		}
	}
	dfs(root, 1);
	for (int i = 1; i < n; i++) {
		cout << color[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 9600
#include <complex>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;

const double EPS = 1e-12;
typedef complex<double> P;

long long pow_binary_mod(long long x,long long y,long long M){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%M;
		x=x*x%M;
	}
	return z;
}

int main(){
	int M=998244353;
	int N,x,y;
	scanf("%d",&N);
	vector<P>v(N);
	int r=pow_binary_mod(2,N,M);
	set<pair<int,int> >se;
	for(int i=0;i<N;i++)scanf("%d%d",&x,&y),v[i]={(double)x,(double)y};
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		if(se.find({i,j})!=se.end())continue;
		vector<int>x={i,j};
		for(int k=0;k<N;k++)if(k!=i&&k!=j&&abs(imag(conj(v[j]-v[k])*(v[i]-v[k]))) < EPS)x.push_back(k);
		for(int a=0;a<x.size();a++)for(int b=a+1;b<x.size();b++){
			int n=b-a-1;
			r=(r-pow_binary_mod(2,n,M))%M;
			se.emplace(x[a],x[b]);
		}
	}
	printf("%d\n",((r-N-1)%M+M)%M);
}

Measured memory_bytes: 1152
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>

using namespace std;

int main(){
	int n,m;
	int ans,tmp;
	map<int, int> a;
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		cin >> tmp;
		a[tmp]++;
	}

	for (int i = 1; i < n+1 ; i++) {
		cout << a[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 12556
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll in=n-1,ans=LLONG_MAX,cow=0,rep=0;
    for(int i=0;i<n;i++)
        if(s[i]=='W')
            cow++;
    ans=cow;
    while(in>=0)
    {
        if(s[in]=='R')
            rep++;
        else
            cow--;
        if(rep<=cow)
            ans=min(ans,cow);
        in--;
    }
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 3940
import java.util.Scanner;

/**
 * 消費税率が
8
 %のとき
A
 円、
10
 ％のとき
B
 円の消費税が課されるような商品の税抜き価格を求めてください。

ただし、税抜き価格は正の整数でなければならないものとし、消費税の計算において小数点以下は切り捨てて計算するものとします。

条件を満たす税抜き価格が複数存在する場合は最も小さい金額を出力してください。また、条件を満たす税抜き価格が存在しない場合は -1 と出力してください。
 * @author nkyy0
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 数字の入力
        int A = sc.nextInt();
        int B = sc.nextInt();
        int target = 0;
        int kekka = 10000;

        while (target < 10000) {
            if ((int) Math.floor((double) target * 0.08) == A && (int) Math.floor((double) target * 0.1) == B) {
                // 出力
              System.out.println(target);
                    break;

            } else {
                target = target + 1;
            }
        }
        if (target == 10000) {
            System.out.println(-1);
        }

    }
}

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

int main(){
  char b;
  cin >> b;
  char ans;
  if(b=='A'){ans='T';}
  else if(b=='C'){ans='G';}
  else if(b=='G'){ans='C';}
  else if(b=='T'){ans='A';}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,MIN=INT_MAX,MAX=INT_MIN;
int arr[101];
int ans,cost;

int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;++i)
	{
		scanf("%d",&arr[i]);
		MIN=min(MIN,arr[i]);
		MAX=max(MAX,arr[i]);
	}
	ans=INT_MAX;
	for(int i=MIN;i<=MAX;++i)
	{
		cost=0;
		for(int j=0;j<N;++j)
		{
			cost+=pow(abs(arr[j]-i),2);
		}
		ans=min(ans,cost);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        h: [usize; n],
    }
    let mut max = 0;
    let mut count = 0;
    for i in 0..n {
        if h[i] >= max {
            max = h[i];
        } else {
            count += 1;
        }
    }
    println!("{}", n - count);
}


Measured memory_bytes: 4352
import sys
read=sys.stdin.read

def main():
  n,h,*ab=map(int,read().split())
  tops=max(ab[0::2])
  tlst=[b for b in ab[1::2] if b>tops]
  tlst.sort(reverse=True)
  i=-1
  t=0
  for i,t in enumerate(tlst):
    h-=t
    if h<=0:
      h=0
      break
  print(h//tops+(h%tops>0)+i+1)

if __name__=='__main__':
  main()


Measured memory_bytes: 32212
#include <iostream>

using namespace std;

int main()
{
    int n,shuzu[20];
    cin >> n;
    int a=0,b;
    while(a<n)
    {
        cin >> b;
        shuzu[a]=b;
        a++;
    }
    int m=shuzu[0],num=1;
    for(int i=1;i<n;i++)
    {
        if(shuzu[i]>=m)
        {
            m=shuzu[i];
            num++;
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    for (int i = 0; i < n; ++i) {
        int a, b, c;
        std::cin >> a >> b >> c;
        if (a * a + b * b == c * c
                || a * a + c * c == b * b
                || b * b + c * c == a * a)
            std::cout << "YES" << std::endl;
        else std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 1152
# 169a
# A×Bを整数として出力せよ。

# 1. 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
# print(a, b)


# 2. 受け取った入力値を使って、適切に処理（計算）すること
answer = a * b


# 3. 計算した結果を出力すること
print(answer)

Measured memory_bytes: 9052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();
			var n = firstLine[0];
			var m = firstLine[1];

			if(2 * n > m)
			{
				Console.WriteLine(m / 2);
			}
			else
			{
				var num = n;
				m -= 2 * n;
				num += m / 4;

				Console.WriteLine(num);
			}
        }
	}
}


Measured memory_bytes: 11348
using System;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var second = Converter(Console.ReadLine());
            Console.WriteLine(Calc(second));
            Console.ReadLine();
        }

        static int Converter(string str)
        {
            return int.Parse(str);
        }

        static string Calc(int second)
        {
            int hour = second / 3600;
            second %= 3600;
            int minutes = second / 60;
            second %= 60;
            return hour + ":" + minutes + ":" + second;
        }
    }
}



Measured memory_bytes: 9156
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;
int main()
{
	char c;
	cin>>c;
	if(c>='a'&&c<='z') printf("a\n");
	  else printf("A\n"); 
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

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

  deque<int> d;
  rep(i,n){
    int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
    if(p==0){
      d.push_front(a[i]);
    } else {
      d[p-1] = a[i];
    }
  }
  int ans=d.size();
  cout << ans << endl;
  return 0;  
}

Measured memory_bytes: 1024
package main

import "fmt"

type UnionFind struct {
	Data []int
}

func (uf *UnionFind) Root(x int) int {
	if uf.Data[x] < 0 {
		return x
	}
	uf.Data[x] = uf.Root(uf.Data[x])
	return uf.Data[x]
}

func (uf *UnionFind) Unite(x, y int) bool {
	rx := uf.Root(x)
	ry := uf.Root(y)
	if rx != ry {
		if uf.Data[rx] < uf.Data[ry] {
			uf.Data[rx], uf.Data[ry] = uf.Data[ry], uf.Data[rx]
		}
		uf.Data[rx] += uf.Data[ry]
		uf.Data[ry] = rx
	}
	return rx != ry
}

func (uf *UnionFind) Same(x, y int) bool {
	return uf.Root(x) == uf.Root(y)
}

func main() {
	var n, q int
	fmt.Scanf("%d %d", &n, &q)

	var uf UnionFind
	uf.Data = make([]int, n)
	for i := 0; i < n; i++ {
		uf.Data[i] = -1
	}

	for i := 0; i < q; i++ {
		var com, x, y int
		fmt.Scanf("%d %d %d", &com, &x, &y)
		if com == 0 {
			// unite
			uf.Unite(x, y)
			continue
		}
		if uf.Same(x, y) {
			fmt.Println(1)
		} else {
			fmt.Println(0)
		}
	}
}



Measured memory_bytes: 5944
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    
    // 入力処理
    ll n; cin >> n;
    vi c(n), s(n), f(n, 1);
    rep(i, n) cin >> c[i] >> s[i] >> f[i];

    // 始点をiとして全てをシミュレート
    for(ll i=0; i<n; i++){
        ll time = s[i]+c[i];
        for(ll j=i+1; j<n; j++){
            // 最初の出発時間を超えていない場合
            if(time < s[j]) time = s[j];
            // 出発時間は過ぎているが発車間隔にあっていない場合
            else if(time%f[j] != 0) time += f[j]-time%f[j];
            // 移動時間を加算
            time += c[j];
        }
        // 結果の出力
        cout << time << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;
int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int n,a[maxn<<1];
ll ans;
ll calc(ll x){
	ll res=0;
	for(int i=1;i<=n;i++)res+=abs(a[i]-x-i);
	return res;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),ans+=abs(a[i]-i);
	ll l=-1e9,r=1e9,res,tmp,m1,m2;
	while(l<r-1){
		m1=(l+r)>>1;
		m2=(m1+r)>>1;
		if(calc(m1)<calc(m2))r=m2;else l=m1;
	}
//	printf("%lld %lld %lld\n",l,r,ans);
	printf("%lld\n",min(ans,min(calc(l),calc(r))));
	return 0;
}

Measured memory_bytes: 1024
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Thu, 20th Jun 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << (x) << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

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

#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define pvi(v)      {for(auto it:v) cout << it << " "; cout << endl;}
#define line1	    printf("---------------------------\n")

// #define wa //
// #define line1 //
// #define pvi //
// #define printf //

void solve();
signed main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	////cout << fixed << setprecision(10);

	int t=1; 
	//cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

const long long INF = 1e18 + 5;

void solve() {

	int n,w;
	cin >> n >> w;

	vi weight(n);
	vi val(n);

	rep(i,0,n) {
		cin >> weight[i] >> val[i];
	}

	int tot_val=0;
	for(auto x:val) tot_val += x;

	// Minimum total weight of objects with total value exactly 'i'
	// Minimum weight for each value 'i'

	// Maximum value for each weight 'i'

	vi dp(tot_val+1, INF);
	dp[0] = 0;

	rep(i,0,n){

		int vi = val[i];
		int wi = weight[i];

		for(int va = tot_val; va >= vi; va--){
			dp[va] = min(dp[va], dp[va-vi] + wi);
		}
	}

	// pvi(dp);

	int ans=0;
	rep(i,0,tot_val+1){
		if(dp[i] <= w) ans=i;
	}

	ret(ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,i,ans=0,minn=1e9,x,to=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		ans+=abs(x);
		minn=min(minn,abs(x));
		if(x<0) to++;
		if(to==2) to=0;
	}
	if(!to) cout<<ans<<endl;
	else cout<<ans-2*minn<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()
number = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
if s[a] == "-":
    if all(s[:a][i] in number for i in range(a)) and all(s[a + 1:a + b + 1][i] in number for i in range(b)):
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

int main(void) {
  int N, K;

  cin >> N >> K;

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (h[i] >= K)
      ans++;
  }

  cout << ans << endl;

  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define DIM (long long)23
#define INF (long long)100000007

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pairll;

ll n,m,i,j,sum,f1,f2,v1,v2,k,x,y,l,nn,z;
ll a[DIM][DIM];
ll step[DIM];
ll dp[10000007];
ll mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(i=1; i<=n; i++){
        for(j=1; j<=n; j++){
            cin >> a[i][j];
        }
    }
    step[0]=1;
    step[1]=2;
    for(i=2; i<=21; i++) step[i]=step[i-1]*2;
    z=step[n];
    dp[0]=1;
    for(j=1; j<z; j++){

        m=j;

        nn=__builtin_popcount(m);

        ll k=0;

        while(m>0){

            if(m%2==1 && a[nn][k+1]==1) dp[j]+=dp[j-step[k]];
            ////cout << j << " " << j-step[k] << endl;
            if(dp[j]>mod) dp[j]%=mod;
            m/=2;
            k++;
        }

    }
    cout << dp[z-1] << endl;










    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}

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

bool isPrime(int x) {
  for(int i = 2; i*i <= x; ++i) {
    if(x % i == 0) return false; 
  }
  return true;
}

int main() {
  for(int n; cin >> n && n;) {
    int res = 0;
    for(int x = n+1; x <= 2*n; ++x) {
      if(isPrime(x)) ++res;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>



using namespace std;

int main(){
  int N;
  cin >> N;
  double sum = 0;

  string JPY = "JPY";
  for(int i = 0; i < N; i++){
    string x, u;
    cin >> x >> u; 
    if(u == JPY){
      // 日本円
      sum += stoi(x);
    }else{
      double btc = stod(x);
      sum += (380000 * btc);
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

void display(vector<int> &v){
  cout <<v[0];
  FOR(i, 1, v.size()) cout <<" " <<v[i];
  cout <<endl;
}

int bubbleSort(vector<int> &v){
  bool changed = 1;
  int cnt = 0;
  while(changed){
    changed = 0;
    for(int i = v.size() - 1; i >= 1; --i){
      if(v[i] < v[i - 1]){
        swap(v[i], v[i - 1]);
        cnt++;
        changed = 1;
      }
    }
  }
  display(v);
  return cnt;
}
 
int main() {
  int N; cin >>N;
  vector<int> v(N);
  REP(i, N) cin >>v[i];
  cout <<bubbleSort(v) <<endl;
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string s;
	cin>>s;
	int ans=s.size();
	int a=s.size();
	for (int i=0;i<s.size()-1;i++){
		if(s[i]!=s[i+1])ans=min(ans,max(i+1,a-1-(i+1)+1));
	}
	cout<<ans<<endl;
}

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

int main(){
	string a,b;
	int n,m;
	int i,j,k,l;
	int s=0,e=0;
	cin>>n>>a;
	for(i=0;i<n;i++){
		cin>>b;
		for(j=0;j<b.size();j++){
			for(k=0;k<b.size();k++){
				e=0;
				for(l=0;l<a.size();l++){
					if(j+k*l>=b.size() || b[j+k*l]!=a[l]){
						e=1;
						break;
					}
				}
				if(e==0){
					e=2; s++;
					break;
				}
			}
			if(e==2){
				e=0; break;
			}
		}
	}
	cout<<s<<endl;
	return 0;			
}

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

template <class Monoid> struct SegmentTree{
    using Func = function<Monoid(Monoid, Monoid)>;

    int size;
    vector<Monoid> seg;
    const Func merge;
    const Monoid def;

    SegmentTree(int n, Monoid d, const Func f): merge(f), def(d){
        for(size = 1; size <= n; size <<= 1);
        seg.assign(size*2, def);
    }

    Monoid& operator[] (int i) { return seg[i+size]; };
    void build(){ for(int i = size-1;i >= 0;i--) seg[i] = merge(seg[i*2], seg[i*2+1]); }

    void update(int i, Monoid val){
        seg[i += size] = val;
        while(i >>= 1) seg[i] = merge(seg[i*2], seg[i*2+1]);
    }

    void add(int i, Monoid val){ update(i, val+seg[i+size]); }

    Monoid get(int a, int b){
        Monoid l = def, r = def;
        for(a += size, b += size; a < b; a >>= 1, b >>= 1){
            if(a & 1) l = merge(l, seg[a++]);
            if(b & 1) r = merge(r, seg[--b]);
        }
        return merge(l, r);
    }
};

int n, m;
string s;
signed main(){
    cin >> n >> m;
    n++;
    cin >> s;

    SegmentTree<pair<int, int> > seg(n, {LLONG_MAX, -1}, [](auto a, auto b){
            return min(a, b);});

    seg.update(n-1, {0, n-1});

    int aa[100010];
    for(int i = n-2;i >= 0;i--){
        if(s[i] == '1'){
            seg.update(i, {LLONG_MAX, -1});
        }else{
            auto r = seg.get(i+1, min(i+m+1, n));
            if(r.first == LLONG_MAX){
                cout << -1 << endl;
                return 0;
            }else{
                seg.update(i, {r.first+1, i});
                aa[i] = r.second-i;
            }
        }
    }

    vector<int> ans;
    int idx = 0;
    while(idx < n-1){
        ans.push_back(aa[idx]);
        idx += aa[idx];
    }

    cout << ans[0];
    for(int i = 1;i < ans.size();i++){
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 6392
#include<stdio.h>
int main()
{
    int a,i,sum=0;
    for (i = 0; i < 5; i++)
    {
        scanf("%d", &a);
        if (a < 40)
        {
            sum += 40;
        }
        else
        {
            sum += a;
        }
    }
        printf("%d\n", sum/5);
    return 0;
}

Measured memory_bytes: 1780
// inputに入力データ全体が入る
function Main(input) {
  	var S = input.split("\n")[0];
 
  	console.log("x".repeat(S.length));
  	return;
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

class DisjointSet {
   int N;
   int ncomp;
   vector<int> par;
   vector<int> sz;

public:
   DisjointSet(size_t _N) : N(_N), ncomp(_N), par(_N, -1), sz(_N, 1) {}
   int num_comp() const {
      return ncomp;
   }
   int size(int u) {
      return sz[ find_rep(u) ];
   }
   int find_rep(int u) {
      return par[u] < 0 ? u : par[u] = find_rep(par[u]);
   }
   bool union_rep(int u, int v) {
      int u_root = find_rep(u);
      int v_root = find_rep(v);
      if (u_root == v_root)
         return false;
      if (sz[u_root] < sz[v_root])
         swap(u_root, v_root);
      par[v_root] = u_root;
      sz[u_root] += sz[v_root];
      --ncomp;
      return true;
   }
};


int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, M, K;
   cin >> N >> M >> K;
   DisjointSet dset(N);
   VVI friends(N);
   REP(m, M) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      dset.union_rep(u, v);
      friends[u].push_back(v);
      friends[v].push_back(u);
   }

   VVI blocked(N);
   REP(k, K) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      blocked[u].push_back(v);
      blocked[v].push_back(u);
   }

   REP(u, N) {
      int res = dset.size(u)-1 - SZ(friends[u]);

      for (int v : blocked[u])
         if (dset.find_rep(v) == dset.find_rep(u))
            --res;

      cout << res << ' ';
   }
   cout << '\n';

   return 0;
}


Measured memory_bytes: 12664
main(){
  unsigned int i,j,a,b;
  while(scanf("%d %d",&a,&b)!=-1){
    if(a<b){
      for(i=1;b%(a/i);)
	for(i++;a%i;i++)
	  ;

      //for(i=a;a%i||b%i;i--);
      for(j=1;a/i*j%b||a/i*j%a;j++)
	;
      printf("%d %d\n",a/i,a/i*j);
    }else{
      for(i=1;a%(b/i);)
	for(i++;b%i;i++)
	  ;
      //for(i=b;a%i||b%i;i--);
      //for(j=b/i;j%a;j+=b/i)
    //	;
      for(j=1;b/i*j%a||b/i*j%b;j++)
	;
      printf("%d %d\n",b/i,b/i*j);
    }

  }
  return 0;
}

Measured memory_bytes: 408
import Control.Monad
import qualified Data.Map as M

main :: IO ()
main = do
  n <- readLn
  ss <- replicateM n getLine
  print $ solve ss

solve :: [String] -> Int
solve = calc . count . filter (`elem` "MARCH") . map head
  where
    count   = foldr (\k mp -> M.insertWith (+) k 1 mp) m0
    m0      = M.fromList $ zip "MARCH" $ repeat 0
    calc mp = sum [ mp M.! x * mp M.! y * mp M.! z | [x, y, z] <- ks ]
    ks      = [ "MAR", "MAC", "MAH", "MRC", "MRH"
              , "MCH", "ARC", "ARH", "ACH", "RCH"]


Measured memory_bytes: 48508
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

int main() {
  int n;
  cin >> n;
  int b[100];

  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      ans += b[i];
    } else if (i == n - 1) {
      ans += b[i - 1];
    } else {
      ans += min(b[i-1], b[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int


def solve(L: int, R: int):
    LmM = L % MOD
    minimum = L - LmM + MOD
    if minimum < R:
        print(str(0))
    else:
        result = 10**16
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                result = min(result, i*j % MOD)
        print(result)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0)
    cout << "Zero" << endl;
  else if (a > 0 || (min(b, (ll)0) - a) % 2 == 1)
    cout << "Positive" << endl;
  else
    cout << "Negative" << endl;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;

signed main() {
  int N, K;
  cin>>N>>K;
  int ans = 0;
  vector<int> ex;
  for (int i = 1; i <= N; i++) {
    if (i >= K) {
      ans += N-i+1;
      break;
    }
    for (int j = 1; j < K; j++) {
      if (i*pow(2, j) >= K) {
        ex.push_back(j);
        break;
      }
    }
  }
  double res;
  if (ex.size() > 0) {
  int max = *max_element(ex.begin(), ex.end());
  ans *= pow(2, max);
  for (int i = 0; i < ex.size(); i++) {
    ans += pow(2, max-ex[i]);
  }
  res=ans/(N*pow(2,max));
  } else {
    res=ans/N;
  }
  cout << fixed << setprecision(15) << res << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int f(int n){
  if(n < 0) return 0;
  if(n%4 == 0) return n;
  if(n%4 == 1) return 1;
  if(n%4 == 2) return n+1;
  if(n%4 == 3) return 0;
  return n;
}

signed main() {
  int A, B; 
  cin >> A >> B;

  cout << (f(B)^f(A-1)) << "\n";

  return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

LL DP[10][10];//[from][to] fromからtoへ変換するのに必要なエネルギー
int H,W;

int main(){
 
    cin>>H>>W;
    REP(i,10)REP(j,10){
        cin>>DP[i][j];
    }

    // REP(i,10){
    //     REP(j,10){
    //         cout<<DP[i][j];
    //     }
    //     cout<<endl;
    // }
    //ここでDPを用いてある数字を１に変換するのに必要な手数を調べる？？
    // while(true){
    //     bool ischanged=false;
    //     REP(from,10)REP(to,10)REP(X,10){
    //         LL old=DP[from][to];
    //         LL old1=DP[from][X];
    //         LL old2=DP[to][X];
            
    //         DP[from][to]=min(DP[from][X]+DP[X][to],DP[from][to]);
    //         DP[from][X]=min(DP[from][to]+DP[to][X],DP[from][X]);
    //         DP[to][X]=min(DP[to][from]+DP[from][X],DP[to][X]);
            
    //         ischanged= (DP[from][to]!=old)||(DP[from][X]!=old1)||(DP[to][X]!=old2);
    //     }
    //     if(ischanged==false){break;}
    // }
  
    REP(X,10)REP(from,10)REP(to,10){
       
        
        DP[from][to]=min(DP[from][X]+DP[X][to],DP[from][to]);
      
    }
    LL ans=0;
    REP(i,H)REP(j,W){
        int a;
        cin>>a;
        if(a==-1){continue;}
        ans+=DP[a][1];
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 384
alpha = input()

Latter = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
          'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

if alpha in Latter:
  print('A')
else:
  print('a')

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

// 插入此處

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int X, Y, Z; cin >> X >> Y >> Z;
	cout << Z << ' ' << X << ' ' << Y << endl;
	return 0;
}


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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    string s; cin >> s;
    vi count(3);
    bool ok = false;
    REP(i, s.length()) count[s[i]-'a']++;
    if(*max_element(ALL(count)) <= *min_element(ALL(count))+1) ok = true;
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Theater
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int li, ri;
    scanf("%d%d", &li, &ri);
    sum += ri + 1 - li;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
s=input()
if "N" in s:
    if "S" in s:
        pass
    else:
        print("No")
        exit()
if "E" in s:
    if "W" in s:
        pass
    else:
        print("No")
        exit()
if "S" in s:
    if "N" in s:
        pass
    else:
        print("No")
        exit()
if "W" in s:
    if "E" in s:
        pass
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 9128
h,w=map(int,input().split())
mass=[]
frame=[["."]*(w+2) for i in range(h+2)]
for i in range(h):
    mass.append(list(input()))
for i in range(h):
    for j in range(w):
        frame[i+1][j+1]=mass[i][j]
for i in range(1,h):
        for j in range(1,w):
            if frame[i][j]=="#" and frame[i][j]!=frame[i][j+1] and frame[i][j]!=frame[i+1][j] and frame[i][j]!=frame[i][j-1] and frame[i][j]!=frame[i-1][j]:
                    print("No")
                    exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pi pair<int,int>
#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b);i++)
#define repv(vec,v) for(v=(vec).begin(); v!=(vec).end();v++)
#define sz(vec) (int)(vec).size()
#define PB push_back
#define F first()
#define S second()


int main(){
	//char s[200005], left[100001], right[100001];
	string s,left,right;
	//int il=0,ir=0;
	cin >> s;
	ll q; cin >> q;
	int s1,s2; char c; int rev=0;
	rep(i,1,q){
		cin >> s1;
		if(s1==1){
			rev++;
			swap(left,right);
			//swap(il,ir);
		} else{
			cin >> s2 >> c;
			if(s2==1)
				//left[il++] = c;
				left  += c;
			else 
				//right[ir++] = c;
				right += c;
		}
	}
	//left[il] = right[ir] = '\0';
	//for(int i=il-1;i>=0;i--)
		//cout << left[i];
	//if(reverse%2==0)
		//rep(i,0,strlen(s))
			//cout << s[i];
	//else
		//for(int i=strlen(s)-1;i>=0;i--)
			//cout << s[i];
		
	//rep(i,0,strlen(right))
		//cout << right[i];
	
	
	if(rev%2==1){
		//swap(left,right);
		reverse(s.begin(),s.end());
	}
	//else{
		reverse(left.begin(),left.end());
		//}
	cout << left;
	cout << s;
	cout << right;
	
	return 0;
}


Measured memory_bytes: 1088
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int a, b, c, x;
    scanf("%d %d %d", &a, &b, &c);
    for (int i = a; i <= b; i++){
        if(c % i == 0){
            x++;
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3224
import sys
sys.setrecursionlimit(int(1e6))

N = int(input())

a = 1
while (a <= 9):
    if ((N % a) == 0) and ((N // a) <=9):
        break
    a += 1

if a <= 9:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define N 100010

ll n;
char s[N];

int main() {
	while(scanf("%s", s)!=EOF){
		n = strlen(s);
		int pos = true;
		if(s[n-1]=='1' || s[0]=='0'){
			pos = false;
		}
		int q = 0;
		for(int i=0; i<n/2; i++){
			if(s[i]!=s[n-2-i]){
				pos = false;
			}
			if(s[i]=='1'){
				q++;
			}
		}
		if(pos==false){
			printf("-1\n");
			continue;
		}
		vector<pair<int, int> > v;
		int edg = n-1;
		for(int i=0; i<q; i++){
			v.push_back(ii(i, i+1));
			edg--;
		}
		int vert = q + 1, last = 0;
		//for(int i=0; i<=q; i++){
		for(int i=0; i<n/2; i++){	
			if(s[i]=='0'){
				v.push_back(ii(last, vert++));
				edg--;
			}
			else{
				last++;
			}
		}
		for(int i=0; i<edg; i++){
			v.push_back(ii(q, vert++));
		}
		for(int i=0; i<n-1; i++){
			printf("%d %d\n", v[i].first+1, v[i].second+1);
		}	
	}
	return 0;
}

Measured memory_bytes: 2420
#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--)
int main(){
	while(true){
		int w,d;
		cin>>w>>d;
		if(!(w||d)){
			break;
		}
		vector<int> a(w);
		vector<int> b(d);
		REP(i,w){
			cin>>a[i];
		}
		REP(i,d){
			cin>>b[i];
		}
		sort(a.begin(),a.end(),greater<int>());
		sort(b.begin(),b.end(),greater<int>());
		int wn=0;//???????????´???
		int dn=0;//???????????´???
		int ans=0;
		while(true){
			if(a[wn]==b[dn]){
				ans+=a[wn];
				wn++;
				dn++;
			} else if(a[wn]>b[dn]){
				ans+=a[wn];
				wn++;
			} else {
				ans+=b[dn];
				dn++;
			}
			if(wn==w){
				while(dn<d){
					ans+=b[dn];
					dn++;
				}
				break;
			}
			if(dn==d){
				while(wn<w){
					ans+=a[wn];
					wn++;
				}
				break;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3016
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

int c(const void*x,const void*y){return strcmp((char*)x,(char*)y);}

char s[99];
char ss[600][99];
int main(){
	ll cnt;
	scanf("%lld",&cnt);
	while(cnt--){
		scanf(" %s",s);
		ll n=strlen(s);
		ll cnt=0;
		rep(i,1,n){
			//[0,i),[i,n)に分ける
			char*t=s+i;
			ll x=n-i;
			rep(j,0,i)ss[cnt][j]=s[j    ];rep(j,0,x)ss[cnt][j+i]=t[j    ];ss[cnt][n]=0;cnt++;
			rep(j,0,i)ss[cnt][j]=s[j    ];rep(j,0,x)ss[cnt][j+i]=t[x-1-j];ss[cnt][n]=0;cnt++;
			rep(j,0,i)ss[cnt][j]=s[i-1-j];rep(j,0,x)ss[cnt][j+i]=t[j    ];ss[cnt][n]=0;cnt++;
			rep(j,0,i)ss[cnt][j]=s[i-1-j];rep(j,0,x)ss[cnt][j+i]=t[x-1-j];ss[cnt][n]=0;cnt++;
			rep(j,0,x)ss[cnt][j]=t[j    ];rep(j,0,i)ss[cnt][j+x]=s[j    ];ss[cnt][n]=0;cnt++;
			rep(j,0,x)ss[cnt][j]=t[j    ];rep(j,0,i)ss[cnt][j+x]=s[i-1-j];ss[cnt][n]=0;cnt++;
			rep(j,0,x)ss[cnt][j]=t[x-1-j];rep(j,0,i)ss[cnt][j+x]=s[j    ];ss[cnt][n]=0;cnt++;
			rep(j,0,x)ss[cnt][j]=t[x-1-j];rep(j,0,i)ss[cnt][j+x]=s[i-1-j];ss[cnt][n]=0;cnt++;
		}
		qsort(ss,cnt,99,c);
		ll ans=0;
		rep(i,0,cnt)if(strcmp(ss[i],ss[i+1]))ans++;
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 2040