akhauriyash/Code-Regression huggingface dataset:
// atcoderC++.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main()
{
	int n = 0;
	string a, b;

	cin >> a;
	cin >> b;

	for (int i = 0; i < 3; i++)
	{
		if (a[i] == b[i])
			n++;
	}

	cout << n << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
from collections import defaultdict

def find(x, parent):
    if parent[x] == x:
        return x
    else:
        # keyとvalueが同じ位置に当たるまで親をたどる
        parent[x] = find(parent[x], parent)
        return parent[x]

# 併合
def unite(x, y, parent):
    x = find(x, parent)
    y = find(y, parent)
    if x == y: return

    parent[y] = x

def solve():
    N, K, L = map(int, input().split())
    
    street = [i for i in range(N)]
    train = [i for i in range(N)]

    for _ in range(K):
        a, b = map(int, input().split())
        unite(a-1, b-1, street)

    for _ in range(L):
        a, b = map(int, input().split())
        unite(a-1, b-1, train)

    d = defaultdict(int)
    for i in range(N):
        a = find(street[i], street)
        b = find(train[i], train)
        d[(a, b)] += 1

    ans = []
    for i in range(N):
        a = find(street[i], street)
        b = find(train[i], train)
        ans.append(str(d[(a, b)]))

    print(' '.join(ans))

solve()

Measured memory_bytes: 55924
void main() {
	auto ip = readAs!(int[]), X = ip[0], Y = ip[1];
	writeln(X + Y/2);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
#endif
	string s,t;
	cin>>s>>t;
	if(s.length()+1==t.length()){
		for(int i=0;i<s.length();i++){
			if(s[i]!=t[i]){
				cout<<"No\n";
				return 0;
			}
		}
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (auto& e : p) cin >> e;
  int r = 0;
  for (int i = 1; i < n - 1; i++) r += p[i - 1] < p[i] && p[i] < p[i + 1] || p[i + 1] < p[i] && p[i] < p[i - 1];
  cout << r << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    String fileName = "";


    public void solve() throws IOException {
        int n = nextInt();
        int[][] a = new int[n][n];
        int[][] b = new int[n][n];
        int[][] c = new int[n][n];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = nextInt();
                b[i][j] = a[i][j];
            }
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (a[i][j] < a[i][k] + a[k][j]) {
                        c[i][j]++;
                    }
                    b[i][j] = Math.min(b[i][j], a[i][k] + a[k][j]);
                }
            }
        }
        boolean flag = false;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[i][j] != b[i][j]) {
                    flag = true;
                }
                if (c[i][j] == n - 2) {
                    ans += a[i][j];
                }
            }
        }
        if (flag) {
            out.println(-1);
        } else {
            out.println(ans / 2);
        }
    }

    public void run() {
        try {
            if ("".equals(fileName)) {
                br = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                br = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

}

Measured memory_bytes: 35344
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
    ll N;
    cin>>N;
    vector <ll> a;
    ll cnt = 0;
    a.push_back(0);
    while(cnt<100000){
        ll temp1 = a[cnt]*10+3;
        a.push_back(temp1);
        ll temp2 = a[cnt]*10+5;
        a.push_back(temp2);
        ll temp3 = a[cnt]*10+7;
        a.push_back(temp3);
        cnt++;
    }
    ll ans = 0;
    ll ppp = 0;
    while(1){
        if(a[ppp]<=N){
            string s = to_string(a[ppp]);
            ll seven = 0;
            ll five = 0;
            ll three = 0;
            for(ll i = 0;i<s.size();i++){
                if(s.at(i) == '3'){
                    three = 1;
                }
                if(s.at(i) == '5'){
                    five = 1;
                }
                if(s.at(i) == '7'){
                    seven = 1;
                }
            }
            if((seven+five+three) == 3){
                ans++;
            }
            ppp++;
        }        
        else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m1 = in.nextInt();
		int d1 = in.nextInt();
		int m2 = in.nextInt();
		int d2 = in.nextInt();
		int ans;
		if (m1 < m2 || d1 > d2) {
			ans = 1;
		} else {
			ans = 0;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23764
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 100000000
int i,j,a,n,M[100][100];
void SSSP();
int main(){
  int k, c, u, v;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INF;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&a,&c);
      M[u][a]=c;
    }
  }
  SSSP();
  return 0;
}
void SSSP(){
    int min;
    int d[100],c[100];
    for(i=0;i<n;i++){
        d[i]=INF;
        c[i]=WHITE;
    }
    d[0]=0;
    c[0]=GRAY;
    while(1){
        min=INF;
        int u=-1;
        for(i=0;i<n;i++){
            if(min>d[i]&&c[i]!=BLACK){
                u=i;
                min=d[i];
            }
        }
        if(u==-1)
        break;
        c[u]=BLACK;
        for(a=0;a<n;a++){
            if(c[a]!=BLACK&&M[u][a]!=INF){
                if(d[a]>d[u]+M[u][a]){
                    d[a]=d[u]+M[u][a];
                    c[a]=GRAY;
                }
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%d %d\n",i,d[i]==INF ? -1 : d[i]);
    }
}



Measured memory_bytes: 2052
#!/usr/bin/python3
# -*- coding: utf-8 -*-



M,D = map(int, input().split())
ans = 0
for m in range(2,M+1):
  for d in range(2,D+1):
    d1 = d//10
    d2 = d%10
    if min([d1,d2])>=2 and m==d1*d2:
      ans += 1
print(ans)


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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

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

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

int ans;
int a[3];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(a[0]), read(a[1]), read(a[2]);

    std::sort(a, a + 3);

    ans += a[2] - a[1];
    a[0] += a[2] - a[1];

    ans += (a[2] - a[0]) / 2;
    if((a[2] - a[0]) % 2) ans += 2;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
//参考　http://drken1215.hatenablog.com/entry/2019/04/23/183916
//計算量がわかりやすい
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

const int MOD = 1e9+7;

void add(llong &a, llong b) {a+=b;if(a>=MOD)a-=MOD;}

int H,W,K;

llong solve() {
    vector<vector<llong>> dp(H+1, vector<llong>(W, 0));
    dp[0][0] = 1;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            for (int bit = 0; bit < 1<<(W-1); ++bit) {
                bool ok = true;
                for (int k = 0; k < W-2; ++k) {
                    if ((bit & (1<<k)) && (bit & (1<<(k+1)))) ok = false;
                }
                if (!ok) continue;
                int nj = j;
                if (bit & (1<<j)) nj = j+1;
                else if (j > 0 && (bit & (1<<(j-1)))) nj = j-1;
                add(dp[i+1][nj], dp[i][j]);
            }
        }
    }
    return dp[H][K];
}

int main() {
    cin >> H >> W >> K; K--;
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;


int main(){
    int n;n=5;
    rep(i,n){
        int a;
        cin >> a;
        if(a==0){
            cout << i+1 << endl;
        }
    }
}

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

int main(){
	int n;
	int a, b;
	int i;
	while(1){
		cin >> n;
		if(n == 0) break;

		vector< pair<int, int> > v;
		for(i = 0; i < n; i++){
			cin >> a >> b;
			v.push_back(make_pair(b, a));
		}

		sort(v.begin(), v.end());

		int sum = 0;
		int flag = 1;
		for(i = 0; i < n; i++){
			sum += v[i].second;
			if(sum > v[i].first){
				flag = 0;
				break;
			}
		}

		if(flag){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}



Measured memory_bytes: 3096
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/ICPC/Prelim/1172?year=2011

#include <bits/stdc++.h>

using namespace std;


vector<long long> primes(long long lo, long long hi) { // primes in [lo, hi)
    const long long M = 1 << 14, SQR = 1 << 16;
    vector<bool> composite(M), small_composite(SQR);

    vector<pair<long long, long long>> sieve;
    for (long long i = 3; i < SQR; i += 2) {
        if (!small_composite[i]) {
            long long k = i * i + 2 * i * max(0.0, ceil((lo - i * i) / (2.0 * i)));
            sieve.push_back({2 * i, k});
            for (long long j = i * i; j < SQR; j += 2 * i)
                small_composite[j] = 1;
        }
    }
    vector<long long> ps;
    if (lo <= 2) {
        ps.push_back(2);
        lo = 3;
    }
    for (long long k = lo | 1, low = lo; low < hi; low += M) {
        long long high = min(low + M, hi);
        fill(composite.begin(), composite.end(), 0);
        for (auto &z: sieve)
            for (; z.second < high; z.second += z.first)
                composite[z.second - low] = 1;
        for (; k < high; k += 2)
            if (!composite[k - low]) ps.push_back(k);
    }
    return ps;
}

vector<long long> primes(long long n) { // primes in [0,n)
    return primes(0, n);
}


int main() {
    int n;
    while (true) {
        cin >> n;
        if (n == 0) return 0;

        auto vt = primes(n + 1, 2 * n);
        cout << vt.size() << endl;
    }
}

/*
 * エラトステネスのふるい。
 * 
 */


Measured memory_bytes: 3328
from collections import deque
import sys
input = sys.stdin.readline


n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    _from, to = map(int, input().split())
    edges[_from-1].append(to-1)

start, goal = map(int, input().split())

todo = deque([])
seen = [[False] * n for i in range(3)]
seen[0][start-1] = True
for to in edges[start-1]:
    dim = 1
    dist = 1
    todo.append([to, dim, dist])

while todo:
    node, dim, dist = todo.popleft()
    if seen[dim][node]:
        continue
    seen[dim][node] = True
    dim += 1
    if dim == 3:
        dim = 0
    for to in edges[node]:
        if seen[dim][to]:
            continue
        todo.append([to, dim, dist+1])
        if to == goal-1 and dim == 0:
            print((dist+1)//3)
            exit()

print(-1)

Measured memory_bytes: 62172
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(auto &x : a){
        cin >> x;
    }
    ll sum = accumulate(ALL(a), 0LL);
    ll ans = LLONG_MAX;
    ll lft = 0;
    for(int i = 0; i < n; i++){
        lft += a[i];
        ll rt = sum - lft;
        if(lft >= (n - i - 1)){
            ans = min(ans, abs(rt - lft));
        }
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 1792
program main
  implicit none
  integer :: m, n, i, a, b
  integer, allocatable :: cnt(:)
  read(*, *) n, m
  allocate(cnt(n))
  cnt(:) = 0
  do i = 1, m
    read(*, *) a, b
    cnt(a) = cnt(a) + 1
    cnt(b) = cnt(b) + 1
  end do
  do i = 1, n
    write(*, "(i0)") cnt(i)
  end do
end program main


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  int m = -1, num = -1;
  REP(i,n){
    int a, b;
    scanf("%d %d", &a, &b);
    if(m < a){
      m = a;
      num = b;
    }
  }

  printf("%d\n", num + m);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    cout<<n*n;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int H, W;
    cin >> H >> W;
    vec<string> s(H);
    rep(i, H) cin >> s[i];
    vec<vec<int>> ans(H, vec<int>(W, 0));

    rep(i, H) {
        for (int j = 0; j < W; ++j)
            if (s[i][j] == '#') ans[i][j] = 1;
        for (int j = 1; j < W; ++j)
            if (s[i][j] == '#') ans[i][j] = ans[i][j - 1] + 1;
        for (int j = W - 2; j >= 0; --j)
            if (s[i][j] == '#') ans[i][j] = max(ans[i][j], ans[i][j + 1]);
    }

    rep(j, W) {
        for (int i = 1; i < H; ++i)
            if (s[i][j] == '#') ans[i][j] = max(ans[i][j], ans[i - 1][j] + 1);
        for (int i = H - 2; i >= 0; --i)
            if (s[i][j] == '#') ans[i][j] = max(ans[i][j], ans[i + 1][j]);
    }

    rep(i, H) rep(j, W) {
        if (ans[i][j] == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace BGoodDistance
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inputs[0], d = inputs[1];

            // 座標の取得
            var points = new int[n][];
            for (var i = 0; i < n; i++)
            {
                points[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }

            var count = 0;
            for (var i = 0; i < n - 1; i++)
            {
                for (var j = i + 1; j < n; j++)
                {
                    var distance = CalcDistance(points[i], points[j]);
                    if (distance % 1 == 0) count++;
                }
            }

            // 解答の出力
            Console.WriteLine(count);
        }

        static double CalcDistance(int[] pointA, int[] pointB)
        {
            var sum = pointA.Zip(pointB, (a, b) => Math.Pow(a - b, 2)).Sum();
            return Math.Sqrt(sum);
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

bool vis[(int)1e6 + 10];

void solve() {
    int K;
    cin >> K;
    if (K % 2 == 0) {
        cout << -1 << endl;
        return;
    }

    int cnt = 1;
    int cur = 0;
    while (true) {
        cur = cur * 10 + 7;
        cur %= K;
        if (cur == 0) break;
        if (vis[cur]) {
            cout << -1 << endl;
            return;
        }
        vis[cur] = true;
        cnt++;
    }
    cout << cnt << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}


Measured memory_bytes: 4568
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_W 10000
#define INF LLONG_MAX/4
typedef long long ll;
 
ll dp[MAX_W+1];
 
int main(){
    ll M,N,E;
    int C;
    cin >> M >> N;
    vector<ll> P(M);
    for(ll i = 0 ; i < M ; i++){
        cin >> P[i];
    }
    sort(P.begin(),P.end(),greater<ll>());
    fill(dp,dp+MAX_W+1,INF);
    dp[0] = 0;
    for(ll i = 0 ; i < N ; i++){
        cin >> C >> E;
        for(int j = MAX_W ; j >= 0 ; j--){
            dp[j] = min(dp[j],dp[max(0,j-C)]+E);
        }
    }
    ll res = 0,sum = 0;
    for(int i = 0 ; i < M ; i++){
        sum += P[i];
        res = max(res,sum-dp[i+1]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll h[200010];

void solve(){
  ll n,k;
  cin >> n >> k;
  ll sum = 0;
  rep(i,n){
      cin >> h[i];
  }
  sort(h,h+n,greater<ll>());
  ll rest = k;
  ll ans = 0;
  rep(i,n){
      if(k>=1){
          k--;
      }
      else{
          ans += h[i];
      }
  }

  cout << ans << endl;

}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int s,a,b;
    cin>>s;
	a=s/100,b=s%100;
    bool fa=a>=1&&a<=12,fb=b>=1&&b<=12;
    if(fa&&fb){
    	cout<<"AMBIGUOUS";
    }else if(fa){
        cout<<"MMYY";
    }else if(fb){
        cout<<"YYMM";
    }else{
        cout<<"NA";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
		typedef long long int ll;
			int main(){	
              string S;
              cin>> S;
              
              int zero = 0;
              int one = 0;
              
              for(int i=0; i<S.size(); i++){
                if(S.at(i)=='0') zero++;
                if(S.at(i)=='1') one++; 
              }
              
              cout<< 2*min(zero, one) << endl;
        	}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;


int main(int argc, char **argv) {
    string S;
    cin >> S;

    int res1 = 0, res2 = 0;
    for(int i = 0; i < S.size(); ++i) {
        char ch = i % 2 == 0 ? '0' : '1';
        if(S[i] != ch) ++res1;
    }

    for(int i = 0; i < S.size(); ++i) {
        char ch = i % 2 == 1 ? '0' : '1';
        if(S[i] != ch) ++res2;
    }

    printf("%d\n", min(res1, res2));
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long n,sum=0; cin>>n;
  vector<long long> a(n),b(n,0),c(n);
  for(int i=0; i<n; ++i){ cin>>a[i]; --a[i]; ++b[a[i]];}
  for(int i=0; i<n; ++i){ c[i]=b[a[i]]*(b[a[i]]-1)/2; sum+=b[i]*(b[i]-1)/2;}
  for(int i=0; i<n; ++i) cout<<sum-c[i]+(b[a[i]]-1)*(b[a[i]]-2)/2<<endl;
  return 0;
}


Measured memory_bytes: 7996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
ll dp[110000];
int main()
{
    int n,W;
    cin >> n >> W;
    rep(i,n){
        ll w,v;
        cin >> w >> v;
        for(int j = W;j>=0;--j){
            if(j-w>=0){
            dp[j] = max(dp[j],dp[j-w]+v);
            }
        }
    }
    cout << dp[W] << endl;

    return 0;
}

Measured memory_bytes: 1024
<?php

fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%s', $s);
    $s = str_split($s);
    rsort($s);
    $a = (int) implode('', $s);
    sort($s);
    $b = (int) implode('', $s);
    echo $a - $b;
    echo PHP_EOL;
}

Measured memory_bytes: 6560
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if 0 < i < H-1 and 0 < j < W-1:
                print('.',end="")
            else:
                print('#',end="")
        print('')
    print('')



Measured memory_bytes: 7008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int map[200][200];
int piece[4][100][100];

int main(){
	
	int n, m;
	
	while(true){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> map[j][i];
			}
		}
		
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				cin >> piece[0][j][i];
			}
		}
		
		for(int loop = 0; loop < 3; loop++){
			for(int i = 0; i < m; i++){
				for(int j = 0; j < m; j++){
					piece[loop + 1][j][i] = piece[loop][m - 1 - i][j];
				}
			}
		}
		
		bool check1, check2;
		
		int ans_x = 10000;
		int ans_y = 10000;
		
		check1 = false;
		for(int y = 0; y <= n - m; y++){
			for(int x = 0; x <= n - m; x++){
				for(int loop = 0; loop < 4; loop++){
					check2 = false;
					int first_x = 10000;
					int first_y = 10000;
					for(int dy = 0; dy < m; dy++){
						for(int dx = 0; dx < m; dx++){
							if(piece[loop][dx][dy] != -1){
								if(first_x == 10000){
									first_x = x + dx;
									first_y = y + dy;
								}
								if(map[x + dx][y + dy] != piece[loop][dx][dy]){
									check2 = true;
									break;
								}
							}
						}
						if(check2){
							break;
						}
					}
					if(!check2){
						if(ans_x >= first_x && ans_y >= first_y){
							ans_x = first_x;
							ans_y = first_y;
							check1 = true;
						}
					}
				}
			}
			if(check1){
				break;
			}
		}
		
		if(ans_x == 10000 && ans_y == 10000){
			cout << "NA" << endl;
		}else{
			cout << ans_x + 1 << " " << ans_y + 1 << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////

void solve(){
  ini(N , M);
  priority_queue<int> Q;
  rep(i , N){
    ini(x); Q.push(x);
  }
  rep(i , M){
    int x = Q.top(); Q.pop();
    x = x / 2;
    Q.push(x);
  }
  ll ans = 0;
  whlie(!Q.empty()){
    int x = Q.top(); Q.pop();
    ans += x;
  }
  out(ans);
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll r = min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	r -= min(c, k);
	cout << r << endl;	
	return 0;
}



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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int n;
	cin >> n;
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	vector<int> sum;
	for(int i = 1; i <= n; i++){
		int seki = i;
		for(int j = 2; j <= n; j++){
			seki *= i;
			if(n < seki) break;
			sum.pb(seki);
		}
	}
	sort(sum.begin(), sum.end(), greater<int>());
	cout << sum[0] << endl;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    for(int i = 1;i<=n;i++){
        int x = i * 108/100;
        if(x == n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}

Measured memory_bytes: 3528
#include<stdio.h>
#define N 2000000

int A[N], B[N], C[N];

main(){

  int i, j, k=0, n;
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    if(k < A[i]) k = A[i];
  }
  
  for(i=0; i<=k; i++){
    C[i]=0;
  }
  for(i=0; i<n; i++){
    C[A[i]]++;
  }
  for(i=1; i<=k; i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n; j>=0; j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }
  
  
  for(i=0; i<n; i++){
    printf("%d", B[i]);
    if(i != n-1)
      printf(" ");
    else
      printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 17896
#include <iostream>
#include <vector>

using namespace std;

int N, A[105];
int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
  	scanf("%d", &A[i]);
	}
	int res = 0;
	for (int i = 1; i <= N; i++) {
  	if (A[i] == A[i - 1]) {
			i++;
			res++;
		}
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

#define MAX_E 2001
#define MAX_V 1001
#define INF INT_MAX

typedef struct edge{
    int from;
    int to;
    int cost;
}edge;

edge es[MAX_E];
int cost[MAX_V];

/*
 * negative?????????????????¨????????´?????????-1?????????
 * n:?????????????????°
 * s:????§??????????
 * e:??¨??????????????°
 */
int BellmanFord(int n, int s, int e) {
    //j???negative loop??????????????????????????¨????????????
    int j = 0, update;
    
    //????§?????????????????????????0???????????????????????????????????§
    fill(cost, cost + MAX_V, INF);
    cost[s] = 0;
    
    while (1) {
        update = 0;
        for (int i = 0; i < e; i++) {
            edge e = es[i];
            if
            (
                cost[e.from] != INF
                &&
                cost[e.to] > cost[e.from] + e.cost
            )
            {
                cost[e.to] = cost[e.from] + e.cost;
                update = 1;
            }
        }
        
        // update?????´??°???????????´????????????????????\???cost????????´??°???????????????????????????????????????
        if (!update) return 1;
        
        /*
         * j???n????¶?????????´??????n????????????????????\??????cost?????´??°???????????´????????????
         * negative loop????????¨??????
         */
        if (j > n) return -1;
        j++;
    }
    return 1;
}

int main( ){
    
    int i, V, E, r, u, v, c, rtn;
    edge tmp;
    cin >> V >> E >> r;

    for (i = 0; i < E; i++) {
        cin >> u >> v >> c;
        tmp.cost = c;
        tmp.to = v;
        tmp.from = u;
        es[i] = tmp;
    }
    
    rtn = BellmanFord(V, r, E);
    
    if (rtn == -1){
        cout << "NEGATIVE CYCLE" << endl;
        return 0 ;
    }
    
    for (i=0; i<V; i++) {
        if (cost[i] == INF) {
            cout << "INF" << endl;
        }else{
            cout << cost[i] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1188
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a;
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	ll count = 0;
	f(i, 0, s.length() / 2)
	{
		if (s[i] != s[s.length() - i - 1])
			count += 1;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())
    graph = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, readline().split())
        a -= 1; b -= 1
        graph[a].append(b)
    check = [0] * N

    que = deque()
    cnt = 0

    que.extend(graph[0])
    flag = False
    ans = 'IMPOSSIBLE'
    while len(que) > 0:
        q = que.pop()
        for i in graph[q]:
            if i == N-1:
                ans = 'POSSIBLE'
                flag = True
                break
        if flag:
            break
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 31740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N],dp[N],ans[N];
vector<int>G[N];

void dfs(int u,int p,int R){
    int l=0,r=R;
    while(r-l>1){
        int mid=l+r>>1;
        if(dp[mid]<a[u]) l=mid;
        else r=mid;
    }
    int pre=dp[r];
    dp[r]=a[u];
    ans[u]=R==r?R++:R-1;
    for(int v:G[u]) if(v!=p) dfs(v,u,R);
    dp[r]=pre;
}

main()
{
   cin>>n;
   for(int i=0;i<n;i++) cin>>a[i];
   for(int i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
   }
   fill(dp,dp+n+1,2e9);
   dfs(0,-1,1);
   for(int i=0;i<n;i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 31172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

long long int A, B;

int main(void) {
	cin >> A >> B;

	if ((A + B) % 2 == 0) { cout << (A + B) / 2 << endl; }
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

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

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

  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = x; y <= sqrt(i); y++) {
        for (int z = y; z <= sqrt(i); z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z) {
              cnt += 1;
            }

            else if (x == y || y == z || z == x) {
              cnt += 3;
            }

            else {
              cnt += 6;
            }
          }
        }
      }
    }
    cout << cnt << endl;
  }
}


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

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

const int MAXN = 1e2 + 5;
const ld PI = acos(-1.0);

int N;
pii p[MAXN];
map <pii, int> idx;
vector <pii> g, d, hull;
ld sol[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &p[i].first, &p[i].second);
		idx[p[i]] = i;
	}
}

bool ccw(pii a, pii b, pii c) {
	return (ll)a.first * (b.second - c.second) + (ll)b.first * (c.second - a.second) + (ll)c.first * (a.second - b.second) >= 0;
}

ld dot(pii a, pii b) {
	return (ld)a.first * b.first + (ld)a.second * b.second;
}

void solve() {
	sort(p, p + N);
	
	for (int i = 0; i < N; i++) {
		while (g.size() > 1 && ccw(g[(int)g.size() - 2], g.back(), p[i]))
			g.pop_back();
		g.push_back(p[i]);
	}
	
	for (int i = N - 1; i >= 0; i--) {
		while (d.size() > 1 && ccw(d[(int)d.size() - 2], d.back(), p[i]))
			d.pop_back();
		d.push_back(p[i]);
	}	
		
	for (int i = 1; i < g.size(); i++)
		hull.push_back(g[i]);
	
	for (int i = 1; i < d.size(); i++)
		hull.push_back(d[i]);
	
	int sz = hull.size();
	for (int i = 0; i < sz; i++) {
		int curr = idx[hull[i]];
		if (sz == 2) {
			sol[curr] = 0.5;
			continue;
		}
		pii prev = hull[(i - 1 + sz) % sz];
		pii nxt = hull[(i + 1) % sz];
		pii x = {prev.first - hull[i].first, prev.second - hull[i].second};
		pii y = {nxt.first - hull[i].first, nxt.second - hull[i].second};
		sol[curr] = 0.5 - acos(dot(x, y) / sqrt(dot(x, x) * dot(y, y))) / (2 * PI);
	}
	
	for (int i = 0; i < N; i++)
		printf("%.20Lf\n", sol[i]);
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  int N,M;
  cin >> N >> M;
  int tmp = N * (N - 1) / 2 + M * (M - 1) / 2;
  cout << tmp << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
int main()
{
    ll n,a=0;
    scanf("%lld",&n);
    if(n==1)
        a=1;
    else
    {
        ll cnt=1;
        a=1;
        while(n>1)
        {
            n=n/2;
            cnt=cnt*2;
            a=a+cnt;
        }
    }
    printf("%lld\n",a);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

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

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;



signed main(){

#ifndef ONLINE_JUDGE
	//
    //freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);


    int d , t , s;
    cin >> d >> t >> s;
    cout << (d <= t*s ? "Yes\n" : "No\n");

    

    return 0;

}



Measured memory_bytes: 3608
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 



ll cnt[100005];


int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

ll n;
cin>>n;

ll a[n]; ll sum=0;

For(i,0,n)
{
    cin>>a[i];
    cnt[a[i]]+=1;
    sum+=a[i];
}
    
ll m;
cin>>m;

while(m--)
{
    ll x,y;
    cin>>x>>y;
    sum=sum+cnt[x]*(y-x);
    cout<<sum<<endl;
    cnt[y]+=cnt[x];
    cnt[x]=0;
}

return 0;
}

Measured memory_bytes: 5108
n = int(input())
a = list(map(int, input().split()))

m = float("inf")
cnt = 0
ans = 0
for x in a:
    if x < 0:
        cnt += 1
    
    m = min(m, abs(x))
    ans += abs(x)

if cnt%2:
    ans -= m*2

print(ans)

Measured memory_bytes: 64880
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  string s;
  ll k;
  cin >>s >>k;
  ll counter=1;
  ll res;
  rep(i,s.size()){
    if(s[i]!='1'){
      res=(int)s[i]-(int)'0';
      break;
    }
    counter++;
  }
//  cout << counter << endl;
  //when counter, first non1 appear;
  if(counter<=k)cout << res << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[100000],ans;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  for(int i=0,j=0;i<n;i=j){
    while(a[i]==a[j]&&j<n)j++;
    if((j-i)%2) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll MX = ll(1e9)+7;
int main(){
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,n) {
        int a;
        cin >> a;
        m[a]++;
    }
    for(auto p : m) {
        if(p.second > 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 12940
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n),v(n + 1,0);
    ll ans = 0;
    for(ll i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    for(ll i = n - 1;i >= 0;i--)
    {
        v[i] = v[i + 1] + a[i];
    }
    for(ll i = 0;i < n;i++)
    {
        ans = (ans + ((v[i] - a[i]) % MOD * a[i]) % MOD) % MOD;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d;
  int s;
  int y;
  int x;
  while(cin>>d){
    s = 0;
    x = d;
    y = d*d;
    while(1){
      if(x == 600){
	break;
      }
      s += (y*d);
      x += d;     
      y = x*x;
      
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 1160