akhauriyash/Code-Regression huggingface dataset:
// Date: 2020-03-14

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 400 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL dp[N][N], a[N], sum[N];

int main() {
    FIO;
    int n; cin >> n;
    rep(i, 1, n) rep(j, 1, n) dp[i][j] = INF;
    rep(i, 1, n) cin >> a[i], dp[i][i] = 0, sum[i] = sum[i-1] + a[i];
    rep(len, 1, n) rep(i, 1, n-len) {
        int j = i+len;
        rep(k, i, j-1) chkmin(dp[i][j], dp[i][k] + dp[k+1][j] + sum[j]-sum[i-1]);
    }
    cout << dp[1][n];

    return 0;
}

Measured memory_bytes: 1536
from functools import reduce
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(nums):
    return reduce(lcm_base, nums, 1)

n, a = input(), list(map(int, input().split()))
l = lcm(a)
sum = 0
for aa in a:
    sum += (l-1) % aa
print(sum)


Measured memory_bytes: 3812
import sys
sys.setrecursionlimit(10**9)

N= int(input())

G = [[] for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append([b-1, i])

ans = [None]*(N-1)

def func(prt, col):
    cnt = 1
    for cld, org in G[prt]:
        if cnt==col:
            cnt += 1
        ans[org] = cnt
        func(cld, cnt)
        cnt += 1

func(0, 0)

print(max(ans))
for i in range(N-1):
    print(ans[i])

Measured memory_bytes: 70984
/**
*    author:  yuya1234
*    created: 24.06.2020 16:55:05
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s;
    cin>>s;

    bool flg;
    int ans = 0;

    FOR(i,97,97+25)
    {
        REP(j,s.size())
        {
            flg=false;
            if(s[j]==(char)i)
            {
                flg=true;
                break;
            }
        }
        if(!flg)
        {
            ans=i;
            break;
        }
    }

    if(ans==0)cout<<"None"<<endl;
    else cout<<(char)ans<<endl;

    return 0;
}

Measured memory_bytes: 3712
import heapq


def construct_graph(A, B, C):
    M = len(A)
    graph = {}
    for i in range(M):
        a = A[i]
        b = B[i]
        c = C[i]
        if a not in graph:
            graph[a] = {}
        if b not in graph:
            graph[b] = {}
        graph[a][b] = c
        graph[b][a] = c
    return graph


def dijkstra(graph, s, t):
    q = [(0, s)]
    fix = set()
    d = {}
    d[s] = 0
    while len(q) > 0:
        cur_d, n = heapq.heappop(q)
        if n in fix:
            continue
        fix.add(n)
        if n == t:
            break
        for v in graph[n]:
            if v in fix:
                continue
            c = graph[n][v]
            if v not in d or d[v] > d[n] + c:
                d[v] = d[n] + c
            heapq.heappush(q, (d[v], v))
    return d[t]


def dijkstra_all(graph, nodes):
    d = {}
    for n in nodes:
        d[n] = {}
        for n2 in nodes:
            if n == n2: 
                continue
            if n2 not in d:
                d[n2] = {}
            d[n][n2] = dijkstra(graph, n, n2)
            d[n2][n] = d[n][n2]
    return d


def tsp_dist(graph):
    graph[-1] = {}
    for n in graph:
        if n == -1: continue
        graph[-1][n] = 0
    return tsp(graph, set(), -1)


def tsp(graph, visited, s):
    if len(visited) + 1 == len(graph):
        return 0
    min_d = None
    for n in graph[s]:
        if n in visited: continue
        c = graph[s][n]
        dist = tsp(graph, visited | set([s]), n) + c
        if min_d is None or min_d > dist:
            min_d = dist
    return min_d


def solve(r, A, B, C):
    graph = construct_graph(A, B, C)
    d = dijkstra_all(graph, r)
    minimum_dist = tsp_dist(d)
    return minimum_dist


def main():
    N, M, R = list(map(int, input().split(' ')))
    r = list(map(int, input().split(' ')))
    A = []
    B = []
    C = []
    for i in range(M):
        a, b, c = list(map(int, input().split(' ')))
        A.append(a)
        B.append(b)
        C.append(c)
    print(solve(r, A, B, C))

if __name__ == '__main__':
    main()


Measured memory_bytes: 7916
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;


class Main{
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n =  in.nextInt();
        int k =  in.nextInt();
        int count = 0;
        while (n != 0){
            n /= k;
            count++;
        }
        out.println(count);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll f[41][41][41], ans;
bool a[41][41];

ll calc(int L, int p, int R) {
	if (L == R) return 1;
	if (f[L][p][R] != -1) return f[L][p][R];
	ll ans = 0;
	for (int i = L; i < p; ++i)
		for (int j = p + 1; j <= R; ++j)
			if (a[i][j])
				for (int k = i; k < p; ++k)
					for (int l = p + 1; l <= j; ++l)
						ans += calc(L, i, k) * calc(k + 1, p, l - 1) * calc(l, j, R);
	return f[L][p][R] = ans;
}

int main() {
	scanf("%d", &n); n *= 2;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) {
			char c = getchar();
			while (!isgraph(c)) c = getchar();
			a[i][j] = c == '1';
		}
	memset(f, -1, sizeof f);
	for (int i = 2; i <= n; ++i)
		if (a[1][i]) ans += calc(2, i, n);
	printf("%lld", ans);
}


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



int main(){

  int n;

  bool p[999999];
  int head;
  int sum;

  while(scanf("%d",&n)!=EOF){

    head = 2;
    sum = 0;

    for(int i=0; i<n; i++){ p[i]=false; }

    while(head<=n){
      
      while(head<=n && p[head-1]==true){ head++; }

      if(!(head>n))sum++;

      for(int i=2; i*head<=n; i++){p[i*head-1]=true;}

      head++;
    }

    cout << sum << endl;
      

  }


  return 0;
}

Measured memory_bytes: 2184
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll M, K;
	cin >> M >> K;

	if(K >= (1<<M)) {
		cout << -1 << endl;
		return 0;
	}

	if (M == 1) {
		if(K == 1) {
			cout << -1 << endl;
			return 0;
		}
		cout << "0 0 1 1" << endl;
		return 0;
	} else {

		rep(i, (1<<M)) {
			if(i == K)continue;
			cout << i << " ";
		}
		cout << K << " ";
		for(ll i = (1<<M) - 1; i >= 0; i--) {
			if(i == K)continue;
			cout << i << " ";
		}
		cout << K << endl;;
	}
}


Measured memory_bytes: 3588
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n,d;cin>>n>>d;
  int a = 1;
  int nw = d+1;
  while(n >= nw){
    if(n <= nw+d){
      cout << a << endl;
      return 0;
    }
    a++;
    nw += d*2+1;
  }
  cout << a << endl;
}


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

using namespace std;

int a[MAXN];
int n, m, d;
int k, num, sum, x, y;
string s;
int t;

int main() {
	scanf("%d%d", &n, &d);
	
	for (int i = 1; i <= n; i++) {
		num = 0;
		for (int j = 2; j <= d / 10; j++) {
			if (i % j == 0 && i / j < 10 && i / j >= 2) {
				num = j * 10 + (i / j);
				if (num <= d) {
					sum ++;
				//	cout << i << " " << j << i / j << endl;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 384
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

int n, m, pr[N], d[N];
bool us[N];
vi g[N];
main() {
  file("threesum");
  ios;
  cin >> n >> m;
  fo(i, 1, m, 1) {
    int u, v;
    cin >> u >> v;
    g[u].eb(v);
    g[v].eb(u);
  }
  queue<int> q;
  fo(i, 2, n, 1) d[i] = INF1;
  q.push(1);
  us[1] = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int to : g[v]) {
      if (!us[to] and d[to] > d[v] + 1) {
        us[to] = 1;
        pr[to] = v;
        d[to] = d[v] + 1;
        q.push(to);
      }
    }
  }
  fo(i, 1, n, 1) if (d[i] == INF1) return !(cout << "No");
  cout << "Yes\n";
  fo(i, 2, n, 1) cout << pr[i] << "\n";
  return 0;
}
/**

*/


Measured memory_bytes: 13260
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>
using namespace std;
#define int long long
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	vector<pair<int, int>> edges;
	vector<vector<int>> adj(n);
	vector<int> deg(n);
	for (int i = 1; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		deg[a]++;
		deg[b]++;
		adj[a].push_back(b);
		adj[b].push_back(a);
		edges.push_back({ a,b });
	}
	vector<int> costs;
	for (int i = 0; i < n; i++)
	{
		int c;
		cin >> c;
		costs.push_back(c);
	}
	sort(costs.begin(), costs.end());
	queue<int> q;
	vector<int> ans(n);
	for (int i = 0; i < n; i++)
	{
		if (deg[i] == 1)
		{
			q.push(i);
		}
	}
	int id = 0;
	while (!q.empty())
	{
		int z = q.front();
		ans[z] = costs[id];
		id++;
		q.pop();
		for (auto i : adj[z])
		{
			deg[i]--;
			if (deg[i] == 1)
			{
				q.push(i);
			}
		}
	}
	long long tot = 0;
	for (auto i : edges)
	{
		tot += min(ans[i.first], ans[i.second]);
	}
	cout << tot << "\n";
	for (auto i : ans)
	{
		cout << i << " ";
	}
	cout << "\n";
}


Measured memory_bytes: 1408
#include"stdio.h"
#include"stdlib.h"
int main()
{
    int i,j;
    int n;
    int *A;
    int buf;
    int count=0;
    scanf("%d",&n);
    A=(int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);   
    }
    for(i=0;i<n;i++)
    {
        for(j=n-1;j>i;j--)
        {
            if(A[j-1]>A[j])
            {
                buf=A[j-1];
                A[j-1]=A[j];
                A[j]=buf;
                count++;
            }
        }
    }
    printf("%d",A[0]);
    for(i=1;i<n;i++)
    {
        printf(" %d",A[i]);
    }
    printf("\n%d\n",count);
    return 0;
}


Measured memory_bytes: 2064
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
string str;
vi hoge;
int main(){
	cin>>N;
	cout<<(N-2)*180<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
const ll INF = (1ll << 60);

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<string> to_add;
  unordered_set<string> s;
  for (ll i = 0; i < N; i++) {
    string c = S.substr(i, 1);
    to_add.clear();
    for (string j : s) {
      if (j.length() < 3) {
        to_add.push_back(j + c);
      }
    }
    for (string j : to_add) s.insert(j);
    s.insert(c);
  }
  ll ans = 0;
  for (auto i : s) if (i.length() == 3) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 384
N = int(input())
T, A = map(int, input().split())
H = map(int, input().split())

near_i = -1
min_diff = 10**6 * 0.006
for i, h in enumerate(H):
    temp = T - h * 0.006
    diff = abs(A - temp)
    if diff < min_diff:
        min_diff = diff
        near_i = i
print(near_i+1)



Measured memory_bytes: 3060
using System;
using System.IO;
using System.Collections.Generic;

namespace ARC097D
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var M = ss.Next(int.Parse);
            var P = ss.Next(int.Parse, N);

            var uf = new UnionFind(N);
            for (var i = 0; i < M; i++)
            {
                uf.Unite(ss.Next(int.Parse) - 1, ss.Next(int.Parse) - 1);
            }

            var ans = 0;
            for (var i = 0; i < N; i++)
            {
                if (uf.IsSameSet(P[i] - 1, i)) ans++;
            }

            sw.WriteLine(ans);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class UnionFind
    {
        private readonly int[] _rank;
        private readonly int[] _p;

        public UnionFind(int size)
        {
            _rank = new int[size];
            _p = new int[size];

            for (var i = 0; i < size; i++)
            {
                _rank[i] = 0;
                _p[i] = i;
            }
        }

        public void Unite(int x, int y)
        {
            x = FindSet(x);
            y = FindSet(y);

            if (_rank[x] > _rank[y]) _p[y] = x;
            if (_rank[x] < _rank[y]) _p[x] = y;
            if (_rank[x] == _rank[y])
            {
                _p[x] = y;
                _rank[y]++;
            }
        }

        public bool IsSameSet(int x, int y)
        {
            return FindSet(x) == FindSet(y);
        }

        public int FindSet(int x)
        {
            if (_p[x] == x) return x;
            return _p[x] = FindSet(_p[x]);
        }
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 31068
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;
vector<vector<bool>> used;

bool dfs (ll x, ll y)
{
    bool f = 0;
    ll nx = 0;
    ll ny = 0;
    
    used[y][x] = 1;
    
    for (int i = 0; i < dx.size(); ++i)
    {
        ll nextx = x + dx[i];
        ll nexty = y + dy[i];
        if (nextx >= 0 && nexty >= 0 && nextx < g[0].size() && nexty < g.size() && g[nexty][nextx] == '#')
        {
            if (used[nexty][nextx])
            {
                continue;
            }
            if (f)
            {
                return 0;
            }
            f = 1;
            if (i == 0 || i == 2)
            {
                nx = nextx;
                ny = nexty;
            }
        }
    }
    if (!f)
    {
        if (x == g[0].size() - 1 && y == g.size() - 1)
        {
            return 1;
        }
        return 0;
    }
    else
    {
        if (x == g[0].size() - 1 && y == g.size() - 1)
        {
            return 0;
        }
    }
    ll ret = dfs(nx, ny);
    return ret;
}


int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll h, w;
    cin >> h >> w;
    vector<string> a(h);
    used = vector<vector<bool>>(h, vector<bool>(w));
    
    for (int i = 0; i < h; ++i)
    {
        cin >> a[i];
    }
    g = a;
    
    if (dfs(0 ,0))
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
a = tuple(map(int, input().split()))

can = True
if n % 3 == 0:
    d = defaultdict(int)
    for aa in a:
        d[aa] += 1
    m = n // 3

    t = []
    for number, cnt in d.items():
        if cnt % m != 0:
            can = False
            break
        else:
            for _ in range(cnt // m):
                t.append(number)
    else:
        if any(t[(0 + i) % 3] ^ t[(1 + i) % 3] != t[(2 + i) % 3] for i in range(3)):
            can = False

else:
    if any(aa != 0 for aa in a):
        can = False

print('Yes' if can else 'No')

Measured memory_bytes: 15364
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	ma := make(map[int]int, N)

	for i, v := range a {
		ma[v] = i+1
	}

	for i:= 1; i <=N; i++ {
		fmt.Println(ma[i])
	}
}


Measured memory_bytes: 8864
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto& v : a) {
		cin >> v;
	}

	sort(begin(a), end(a));

	cout << abs(a[0] - a[n - 1]) << endl;
	return 0;
}


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

#define int ll
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }

template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const {
        return F::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class F>
constexpr decltype(auto) funcs(F &&f) {
    return FixPoint<F>{std::forward<F>(f)};
}

template <class T>
std::vector<T> vecs(int n, T &&val) {
    return std::vector<T>(std::forward<int>(n), std::forward<T>(val));
}

template <class... Args>
decltype(auto) vecs(int n, Args &&... args) {
    return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...));
}

template <class V, class T>
void fill(V &x, const T &val) {
    x = val;
}

template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n, m, x;
    cin >> n >> m >> x;
    auto c = vecs(n, int());
    auto a = vecs(n, m, int());
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    int ans = inf;
    rep(s, 1 << n) {
        auto val = vecs(m, int(0));
        int res = 0;
        rep(i, n) {
            if ((s >> i) & 1) {
                res += c[i];
                rep(j, m) val[j] += a[i][j];
            }
        }

        if (all_of(all(val), [&](auto v) { return v >= x; })) {
            mins(ans, res);
        }
    }

    cout << (ans < inf ? ans : -1) << '\n';
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#ifdef Rahul
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define error(...) 42;
#endif
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n;
  cin >> n;
  map<string,int> cnt;
  while (n--) {
    string s; cin >> s;
    cnt[s]++;
  }
  vector<string> ans;
  int mx = -1;
  for (auto &pr : cnt) {
    if (uax(mx, pr.second)) {
      ans = {};
    }
    if (mx == pr.second) ans.push_back(pr.first);
  }
  sort(ALL(ans));
  for (auto &s  : ans) cout << s << '\n';
}


Measured memory_bytes: 25584
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int N;
	cin >> N;

	vector<string>s(N);
	set<string>S;
	rep(i, 0, N)
	{
		cin >> s[i];
		S.insert(s[i]);
	}
	cout << S.size() << endl;
	
	return 0;
}


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

using namespace std;

const int N = 1e3,M=1e6+20;;

typedef long long ll;
ll v[N],w[N],f[M];

int main()
{
	int n,W;
	cin>>n>>W;
	memset(f,0,sizeof(f));
	for(int i=1;i<=n;i++)	cin>>w[i]>>v[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=W;j>=w[i];j--)
		{
			f[j]=max(f[j],(f[j-w[i]]+v[i]));
		}
	}
	cout<<f[W]<<endl;

	
}

Measured memory_bytes: 8064
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(f, x, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }

class fenwick_tree {
  vector<int> a;
public:
  fenwick_tree(int n) : a(n+1) {}
  void add(int i, int x) {
    int n = ::size(a) - 1;
    for (; i <= n; i += i & -i)
      a[i] += x;
  }
  int psum(int i) const {
    int r = 0;
    for (; i > 0; i -= i & -i)
      r += a[i];
    return r;
  }
};

signed main() {
  const int n = rint();
  pair<int, int> a[n];
  dotimes(i, n) {
    a[i].first = rint();
    a[i].second = i;
  }
  sort(a, a + n);
  dotimes(i, n)
    a[i].first = i + 1;
  sort(a, a + n, [](auto p1, auto p2) { return p1.second < p2.second; });
  fenwick_tree ft(n);
  int r = 0;
  dotimes(i, n) {
    r += i - ft.psum(a[i].first - 1);
    ft.add(a[i].first, 1);
  }
  wint(r);
  return 0;
}



Measured memory_bytes: 7136
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;

//* Author :- Amey :P *//
void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}
 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}






int main(){

//   #ifndef ONLINE_JUDGE
//      freopen("input.txt", "r", stdin);
//   #endif
   ll n;
   cin>>n;
   ll r;
   cin>>r;

   if(n >= 10){
    cout<<r<<endl;
   }else{
    cout<<r+(100*(10-n))<<endl;
   }

}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int N,T;
    scanf("%d %d",&N, &T);
    int c[N], t[N];
    for(int i = 0; i < N; i++){
        scanf("%d %d",&c[i], &t[i]);
    }
    
    int a;
    int b;
    for(int i = 0; i < N; i++){
        a = t[i];
        for(int j = i + 1; j < N; j++){
            if(t[j] < a){
                a = t[j];
                b = c[j];
                t[j] = t[i];
                c[j] = c[i];
                t[i] = a;
                c[i] = b;
            }
        }
    }

    if(t[0] > T){
        printf("TLE\n");

        return 0;
    }
    
    int d = c[0];
    for(int i = 0; t[i] <= T; i++){
        if(c[i] < d){
            d = c[i];
        }
    }

    printf("%d\n",d);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int num[1000] = {};
    rep(i, 1000) num[i]++;
    for (int i = 1; i <= N; i++){
        int j = 2;
        int tmp = i;
        while (tmp > 1) {
            if (tmp % j == 0) {
                num[j]++;
                tmp /= j;
            } else {
                j++;
            }
            //dump(j);
        }
    }
    int ans = 1;
    rep(i ,1000) {
        int prev = ans;
        ans = (ans * num[i]) % mod;
        //printf("%lld * %lld = %lld (mod%lld)\n", prev, num[i], ans, INF);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  int N;cin >> N;
  vll A(N);
  vector<vector<int>> vx(N),vy(N);
  rep(i,N){
    cin>>A[i];
    rep(j,A[i]){
      int x,y;cin>>x>>y;x--;
      vx[i].push_back(x);
      vy[i].push_back(y);
    }
  }
  int ans = 0;
  for(int bit=0;bit<(1<<N);++bit){
    bool flag = true;
    rep(i,N){
      //iが正直者のとき
      if(bit & 1<<i){
        rep(j,A[i]){
          if((bit>>vx[i][j] & 1) != vy[i][j]){
            flag=false;
          }
        }
      }
    }
    if(flag){
    ans = max(ans,__builtin_popcount(bit));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Atcoder89
{
    public static void Main()
    {
        string s = Console.ReadLine();

        int length = s.Length;
        int pluscount = length - s.Replace("+", "").Length;

        int value = pluscount * 1 + (length - pluscount) * (-1);
        Console.WriteLine(value);
    }
}

Measured memory_bytes: 13140
a = input()
b = input()
c = input()
get = 'a'
while True:
  if get == 'a':
    if a == '':
      print('A')
      break
    get = a[0]
    a = a[1:]
  elif get == 'b':
    if b == '':
      print('B')
      break
    get = b[0]
    b = b[1:]
  else:
    if c == '':
      print('C')
      break
    get = c[0]
    c = c[1:]
  #print(get,a,b,c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  
  for(int i; i<N; i++){
    int x;
    cin >> x;
    int a, b;
    a = x;
    b = abs(x-K);
    if (a<b){
      sum += a*2;
    }
    else{
      sum += b*2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
typedef long long ll;

int N, r, a[110], ans;

int main () {
	scanf("%d", &N);
	fo(i, 0, N) scanf("%d", &a[i]);
	fo(l, 0, N) {
		while (r+1 < N && a[r+1] == a[l]) r++;
		ans += (r-l+1)/2;
		l = r;
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    int lmax = 0, rmin = 101010;
    for(int i = 0; i < M; ++i) {
        int l, r; cin >> l >> r;
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }
    int ans = rmin - lmax + 1;
    if(ans < 0) ans = 0;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int N;
  rd(N);
  if(N/100==N%10){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int N;
//   rd(N);
//   wt( if[N/100==N%10, "Yes", "No"] );
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int t = 0, x = 0, y = 0;
  rep(i,0,n) {
    int nt, nx, ny;
    cin >> nt >> nx >> ny;
    int dt = nt - t, dx = abs(nx - x), dy = abs(ny - y);
    if (dt < dx + dy) {
      cout << "No" << endl;
      return 0;
    }
    if ((dt - dx - dy) % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
    t = nt, x = nx, y = ny;
  }
  cout << "Yes" << endl;
  return 0;
}

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


using namespace std;

int main()
{
	long int n;

	scanf("%ld", &n);

	long int sol = ceil(n / (double)11);


	if (sol * 11 - 5 >= n)
	{
		printf("%ld\n", sol * 2 - 1);
	}else
	{
		printf("%ld\n", sol * 2);
	}

	return 0;
}
	

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>


int main() {
  string s;
  cin >> s;
  if(s[0] == s[s.size()-1]){
    if(s.size()%2 == 0) cout << "First" << endl;
    else cout << "Second" << endl;
  }
  else{
    if(s.size()%2 == 1) cout << "First" << endl;
    else cout << "Second" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

n = int(input())
a_l = list(map(int, input().split()))

f = True
for a in a_l:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            print('DENIED')
            f = False
            break

if f:
    print('APPROVED')

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[m];

        if (m == 1) {
            System.out.println(0);
            return;
        }
        for (int i = 0; i < m; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        int[] kyori = new int[m - 1];
        int kIndex = 0;
        for (int i = 1; i < m; i++) {
            kyori[kIndex] = Math.abs(x[i - 1] - x[i]);
            kIndex++;
        }

        int sum = Arrays.stream(kyori).sum();

        Arrays.sort(kyori);

        for (int i = kyori.length - 1; kyori.length - Math.min(n,m) < i; i--) {
            sum -= kyori[i];
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 50416
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265
    /*vl v[10005];
    ll cnt=0;
    ll a[51][51]={0};
    bool visited[10005]={0};
    void dfs(ll u)
    {
        visited[u]=1;
        f(i,0,v[u].size())
        {
            ll f=v[u][i];
            if(!visited[f])
            {
                dfs(f);
            }
        }
    }*/
    void solve()
    {
        in2(n,d);ll c=0;dl a,b;
        f(i,0,n)
        {
            cin>>a>>b;
            if(a*a+b*b<=d*d)
                c++;
        }
        cout<<c;
    }
    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin>>q;
        while (q--)
        {
            //cout<<"           ";
            solve();cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3804
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<map>

using namespace std;
#define ll long long 

int  main(){
    int N;
    int ans = 0;
    cin >> N;
    vector<ll> a(N);
    map<int, ll> b;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(b[a[i]] == 0){
            b[a[i]] = 1;
        }else{
            b[a[i]]++;
        }
    }
    sort(a.begin(), a.end());
    if(a[0] < b[a[0]]){
        ans += b[a[0]] - a[0];
    }else if(a[0] > b[a[0]]){
        ans += b[a[0]];
    }
    for(int i = 1; i < N; i++){
        if(a[i] > a[i-1]){
            // cout << a[i] << " b:" << b[a[i]] << endl;
            if(a[i] < b[a[i]]){
                ans += b[a[i]] - a[i];
            }else if(a[i] > b[a[i]]){
                ans += b[a[i]];
            }
        }
    }
    cout << ans <<endl;
}    

Measured memory_bytes: 7040
A, B, C, D = map(int, input().split())
count = B-A+1

import sys
sys.setrecursionlimit(1000000001)

def euclid(a, b):
    if a%b == 0:
        return b
    return euclid(b, a%b)

def how_many(num):
    ans = B//num-(A-1)//num
    return ans

count -= how_many(C)
count -= how_many(D)
E = C * D // euclid(D, C)
count += how_many(E)

print(count)

Measured memory_bytes: 38512
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;
typedef pair<int,int> P;


int main(){
	
	int a,b;
	while(cin>>a>>b){
	int p[120]={0};
		p[a]++;
		p[b]++;
	while(cin>>a>>b,a!=0||b!=0){
		p[a]++;
		p[b]++;
		
	}
	
	bool f=true;
	for(int i=3;i<101;i++){
			if(p[i]%2!=0){
				f=false;
				break;
			}
	}
	if(f&&p[1]%2&&p[2]%2)
		cout<<"OK"<<endl;
	else
		cout<<"NG"<<endl;
	}
	
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int a[300000];
int main()
{
    long long int m,n,d,re,s=0,k,max=0;
    cin>>k>>n;
    for(int i  = 0; i < n; i++)
    {
        cin>>a[i];
        if(i!=0)
        {
            s += a[i]-a[i-1];
            d = a[i]-a[i-1];
            if(d > max)
            {
                max = d;
            }
        }

    }
    //m = a[n-1] - a[n-2];
    re = a[0]+(k-a[n-1]);

    if(max > re)
    {
        s -= max;
        s += re;
        cout<<s<<endl;
    }
    else
    {
        cout<<s<<endl;
    }


}





Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        long sum = 0;
        int median;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt() - (i + 1);
            sum += arr[i];
        }

        Arrays.sort(arr);
        if (n % 2 == 0)
            median = (arr[(n - 1) / 2] + arr[n / 2]) / 2;
        else
            median = arr[n / 2];

        sum = 0;
        for (int i = 0; i < n; i++) {
            sum += Math.abs(arr[i] - median);
        }
        System.out.println(sum);
    }
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int a[111];

int main() {
   int N;
   cin >> N;
   rep (i, N) cin >> a[i];

   ll cost = 1e15;
   for (int i = -1000; i <= 1000; i++) {
      ll sum = 0;
      rep (j, N) {
         ll x = (i - a[j]);
         sum += x * x;
      }
      cost = min(cost, sum);
   }
   cout << cost << endl;

   return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	while(true){
	    int n=sc.nextInt();
	    int x=sc.nextInt();
	    if(n==0&&x==0)break;
	    int ans=0;
	    for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
		    if(j!=i){
			for(int k=j;k<=n;k++){
			    if(k!=i&&k!=j){
				if(k+j+i==x)ans++;
			    }
			}
		    }
		}
	    }
	    System.out.println(ans);
	}
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 26744
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
  long x;
  long count = 0;
  cin >> x;
  count = x / 11 * 2;
  if(x % 11 > 6){
  	count += 2;
  } else if(x % 11 == 0 ){ 

  }else { 
    count++;
  }
  cout << count << endl; 
}

Measured memory_bytes: 256
n = int(input())
p = 10**9 + 7
dp=[[0]*(2) for i in range(2)]
dp[0][0]=1

for i in range(n):
  nextDP = [[0]*(2) for i in range(2)]
  nextDP[1][1] += (dp[0][1] + dp[1][0] + dp[1][1] * 10) % p
  nextDP[1][0] += (dp[1][0] * 9 + dp[0][0]) % p
  nextDP[0][1] += (dp[0][1] * 9 + dp[0][0]) % p
  nextDP[0][0] += (dp[0][0] * 8) % p
  dp = nextDP
print(dp[1][1] % p)

Measured memory_bytes: 9108
#include <iostream>
#include <iomanip>

#define M_PI 3.1415926535897932384626433832795

using namespace std;
int main(void) {

	double r, s, d;
	cin >> r;

	s = M_PI * r*r;
	d = M_PI * 2 * r;
	cout << std::setprecision(14) << s << " " << std::setprecision(14)<<  d << endl;
	return 0;
}


Measured memory_bytes: 3268