akhauriyash/Code-Regression huggingface dataset:
// Author :: <Hitesh_Saini>
#include<bits/stdc++.h>

#define __speed() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define dbg(x) cout << "--- " << #x << " = " << x << " ---\n";
#define findmax(v) *max_element(v.begin(), v.end())
#define _sum(a) accumulate(a.begin(), a.end(), 0)
#define tt int t;for(cin>>t; t--; )
#define f0(i, n) for(i = 0; i < int(n); i++)
#define f1(i, n) for(i = 1; i<= int(n); i++)
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define endl "\n"

using namespace std;
using mii = map<int, int>;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1e9+7,mxN = 1e6+5;

template<typename... Args>void print(Args... args){((cout << args << " "), ...);cout << endl;}
ll mod_pow(ll x, ll y){ll res = 1;x = x % mod;while(y>0){if(y&1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod; }return res; }ll mod_inv ( ll n ){ll ans = mod_pow ( n , mod - 2 ) ;return ans ;}ll mul(ll a, ll b){a%=mod, b%=mod;return (a*b)%mod;}ll sub(ll a,ll b){a%=mod, b%=mod;return (a-b+mod)%mod;}ll add(ll a, ll b){a%=mod, b%=mod;return (a+b)%mod;}
bool _prime(ll n){if(n<2)return 0;if(n<4)return 1;if(n%2==0||n%3==0)return 0;for(ll i=5;i*i<=n;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}

/* #include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define iset tree<ll , null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define iof order_of_key
#define findat find_by_order */

int n, cache[mxN], A[mxN];
int f(int pos){
	if(pos<=0)
		return 0;
	if(pos==1)
		return abs(A[0]-A[1]);
	if(cache[pos]!=-1)
		return cache[pos];
	return cache[pos]=min(abs(A[pos]-A[pos-2])+f(pos-2), abs(A[pos]-A[pos-1])+f(pos-1));
}

void solve(){//D
	cin >> n;
	int d, x, y, i, ans=0;
	cin >> d;
	f0(i, n){
		cin >> x >> y;
		ans +=sqrt(1ll*x*x+1ll*y*y)<=d;
	}
	print(ans);
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout);
	#endif
    __speed();
    solve();
    return 0;
}

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

int INF = 1e9;
 
int main(void){
    int h, w;
    cin>>h>>w;
    vector<string> v(h);
    rep(i, h) cin>>v[i];
    queue<pair<int, int> > que;
    queue<pair<int, int> > nextque;
    rep(i, h)rep(j, w)if(v[i][j] == '#') que.push(make_pair(i, j));
    int ans = 0;
    bool ok = true;
    vector<int>dx = {0, -1, 0, 1};
    vector<int>dy = {-1, 0, 1, 0};
    while(ok){
        nextque = queue<pair<int, int> >();
        while(!que.empty()){
            auto p = que.front();que.pop();
            rep(i, 4){
                if(p.first+dx[i]>=0 && p.first+dx[i]<=h-1 && p.second+dy[i]>=0 && p.second+dy[i]<=w-1 && v[p.first+dx[i]][p.second+dy[i]] == '.'){
                    v[p.first+dx[i]][p.second+dy[i]] = '#';
                    nextque.push(make_pair(p.first+dx[i], p.second+dy[i]));
                }
            }
        }
        ok = !nextque.empty();
        que = nextque;
        if(ok) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<math.h>
#include<stdio.h>
#define M_PI 3.14159265358979 /* ?????¨??? */

using namespace std;

int main(){
    int len, deg;
    int deg_now = 90;
    double x = 0, y = 0;

    while (1){
        scanf("%d,%d", &len, &deg);
        if (len == 0 && deg == 0) break;
        x += len*cos(deg_now* M_PI / 180);
        y += len*sin(deg_now* M_PI / 180);
        deg_now -= deg;
    }

    cout << (int)x << endl << (int)y << endl;

    return 0;

}

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

bool solve() {
	char c;
	int a = 0;
	while (scanf("%1c", &c)) {
		if (c == '\n') break;
		a = (a + c - '0') % 9;
	}
	return a == 0;
}

int main() {
	printf(solve() ? "Yes" : "No");
	return 0;
}

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

#define ll long long
#define pb push_back
#define ins insert
#define mp make_pair
#define pii pair<int, int>
#define pil pair<int, ll>
#define pib pair<int, bool>
#define SET(a, c) memset(a, c, sizeof(a))
#define MOD 1000000007
#define enld endl
#define endl "\n"
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define found(u, val) u.find(val) != u.end()

#include <string>
#include <vector>
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//#include <algorithm>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <cmath>
//#include <cstring>
//#include <sstream>
//#include <stack>
//#include <queue>

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

    int n, W;
    cin >> n >> W;

    vl values, weights;
    values.resize(n);
    weights.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> weights[i] >> values[i];
    }

    ll dp[n + 1][W + 1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= W; j++) {
            if (i == 0 || j == 0)
                dp[i][j] = 0;
            else if (weights[i - 1] <= j) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weights[i - 1]] + values[i - 1]);
            } else
                dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n][W];
}

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

int main()
{
    int N;
    cin >> N;
    
    if(N >= 1800)
        cout << "1";
    else if(N >= 1600)
        cout << "2";
    else if(N >= 1400)
        cout << "3";
    else if(N >= 1200)
        cout << "4";
    else if(N >= 1000)
        cout << "5";
    else if(N >= 800)
        cout << "6";
    else if(N >= 600)
        cout << "7";
    else if(N >= 400)
        cout << "8";
    return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;

using namespace std;

int solve(int arr[],int n)
{
	int i,j,ans;
    int dp[n];
    memset(dp,0,sizeof(dp));
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n+1;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
   
    return dp[n-1];
}

int main()
{
	FIO
	
		int n;
		cin>>n;
        int arr[n];
        for(int i=0;i<n;i++)cin>>arr[i];
		cout<<solve(arr,n);
	

}

Measured memory_bytes: 4408
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define MOD 1000000007

int *array;

int min(int a, int b) {
    return a<b?a:b;
}

int max(int a, int b) {
    return a>b?a:b;
}

int compare(const void* a, const void* b) {
    return *(int*)a-*(int*)b;
}

int cmp(const void *a, const void *b){
    int ia = *(int *)a;
    int ib = *(int *)b;
    return array[ia] < array[ib] ? -1 : array[ia] > array[ib];
}

int abs(int n) {
    if(n < 0)
        return n*(-1);
    return n;
}

void swap(int *a, int *b) {
    *a = (*a)^(*b);
    *b = (*a)^(*b);
    *a = (*a)^(*b);
}

int binSearch(int a[], int x, int l, int r) {
    if(r >= l) {
        int mid = l + ((r-l)>>1);
        if(a[mid] == x)
            return mid;
        if(a[mid] > x) {
            return binSearch(a, x, l, mid-1);
        }
        else if(a[mid] < x) {
            return binSearch(a, x, mid+1, r);
        }
    }
    return -1;
}

int isRound(int n) {
    int count=0, count_0=0;
    while(n) {
        int x = n%10;
        
        // printf("%d\n", n%10);
        if(x == 0)
            count_0++;
        else
            count++;
        n /= 10;
    }
    if(count == 1)
        return 1;
    return 0;
}

int findRound(int n) {
    int count=0;
    int temp = n;
    while(temp) {
        count++;        
        temp /= 10;
    }
    int power=1;
    for(int i=0;i<count-1;i++)
        power *= 10;
    int res = n - (n%power);
    return res;
}

void testCase() {
    int i;
    char s[14], t[15];
    if(scanf("%s%s", s, t)) {
        for(i=0;s[i];i++) {
            if(s[i] != t[i]) {
                printf("No");
                return;
            }
        }
        printf("Yes");
    }
    
}

int main() {
    int t=1;
    scanf("%d", &t);
    while(t--) {
        testCase();
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int k;
	ll ans=0;
	cin>>k;
	rep(a,1,k+1){
		rep(b,1,k+1){
			rep(c,1,k+1){
				int x = __gcd(a,b);
				ans+=__gcd(x,c);
			}
		}
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






Measured memory_bytes: 3652
S = input()
n = len(S)
cnt1,cnt2 = 0,0
for i in range(n):
    if (i%2==0 and S[i]=='1') or (i%2==1 and S[i]=='0'):
        cnt1 += 1
for i in range(n):
    if (i%2==1 and S[i]=='1') or (i%2==0 and S[i]=='0'):
        cnt2 += 1
print(min(cnt1,cnt2))

Measured memory_bytes: 40304
N = int(input())
S = [0] * N 
check = 0
for i in range(N):
    S[i] = input()

#同じ言葉がないか調べる
A = list(set(S))
if len(A) == len(S):
    pass
else:
    check = 1

for i in range(1, N):
    if S[i][0] == S[i-1][-1]:
        pass
    else:
        check = 1

if check == 0:
    print('Yes')
else:
    print('No')

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

int main(){
	int n, m, ans = 0;
	const int MAX = 1 << 29;
	cin >> n >> m;
	int dist[n][n];
	int a[m], b[m], c[m];
	for (size_t i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
	}
	for(int i=0; i < n; i++) {
		for(int j=0; j < n; j++) {
			dist[i][j] = MAX;
		}
		dist[i][i] = 0;
	}

	for(int i=0; i < m; i++) {
		dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
		dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
	}

	for(int k=0; k < n; k++) {
		for(int i=0; i < n; i++) {
			for(int j=0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	for(int i=0; i < m; i++) {
		if(dist[a[i]][b[i]] < c[i])
			ans++;
	}
	cout << ans << endl;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,a,b,c;
    cin >> n >> a >> b >> c;
    vector<string> Q(n);
    rep(i,n) cin >> Q[i];

    vector<char> ans;
    rep(i,n){
        string s = Q[i];
        int *x, *y;
        if(s == "AB"){ x = &a; y = &b; }
        if(s == "BC"){ x = &b; y = &c; }
        if(s == "AC"){ x = &a; y = &c; }
        if(*x == 0 && *y == 0){
            cout << "No" << endl;
            return 0;
        }else if(*x == 0 || *y == 0){
            if(*x == 0){
                ans.push_back(s[0]), ++*x, --*y;
            }else{
                ans.push_back(s[1]), --*x, ++*y;
            }
        }else{
            if(i == n-1){
                ans.push_back(s[0]), ++*x, --*y;
            }else{
                if(Q[i+1].find(s[1]) == string::npos){
                    ans.push_back(s[0]), ++*x, --*y;
                }else{
                    ans.push_back(s[1]), --*x, ++*y;
                }
            }
        }
    }
    cout << "Yes" << endl;
    for(auto c : ans) cout << c << endl;
    return 0;
}

Measured memory_bytes: 6664
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    long A, B;
    cin >> A >> B;
    long ans = A + B;
    if(ans % 2 == 1 )
        cout << "IMPOSSIBLE" << endl;
    else
        cout << ans / 2 << endl;
    return 0;  

}

Measured memory_bytes: 256
//author: Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    string s,t;
    cin>>s>>t;
    cout<<t+s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <fstream>
struct Coordinate {
	long double x, y, z;
	long double distance(const Coordinate& that) const {
		return std::sqrt((x - that.x) * (x - that.x) + (y - that.y) * (y - that.y) + (z - that.z) * (z - that.z));
	}
};
bool fuzzy_equal(long double a, long double b) {
	return a * 1.0002 > b && b > a * 0.9998;
}
bool match(const std::vector<long double>& original, Coordinate &p, Coordinate &q, Coordinate &r) {
	const auto pq = p.distance(q) / original[0];
	const auto qr = q.distance(r) / original[1];
	const auto rp = r.distance(p) / original[2];
	return fuzzy_equal(pq, qr) && fuzzy_equal(qr, rp);
}
int main(){
	int time; std::cin >> time;
	for (auto t = 0; t < time; ++t) {
		std::vector<long double> original(3); for (auto& len : original) std::cin >> len;
		int s; std::cin >> s;
		std::vector<Coordinate> suspects(s); for (auto& c : suspects) std::cin >> c.x >> c.y >> c.z;
		bool found = false;
		int p{ -1 }, q{ -1 }, r{ -1 };
		for (auto i = 0; i < s && !found; ++i) {
			for (auto j = 0; j < s && !found; ++j) if (i != j) {
				for (auto k = 0; k < s && !found; ++k) if (i != k && j != k) {
					if (match(original, suspects[i], suspects[j], suspects[k])) {
						p = i; q = j; r = k;
						found = true;
					}
				}
			}
		}
		std::cout << r + 1 << ' ' << p + 1 << ' ' << q + 1 << '\n';
	}
}



Measured memory_bytes: 3200
#include<stdio.h>
#include<string.h>

int main(void){
  int i=0;
  char text[20]={};
  char x;
  scanf("%s",text);
  while(i<=(strlen(text)-1)/2){
    x = text[i];
    text[i] = text[strlen(text)-1-i];
    text[strlen(text)-1-i] = x;
    i++;
  }
  printf("%s\n",text);
  return(0);
}

Measured memory_bytes: 1716
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    ArrayList<Integer> list = new ArrayList<Integer>();
    for (int i = 0; i < N; i++) {
      list.add(sc.nextInt());
    }
    Collections.sort(list, Collections.reverseOrder());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < N; i++) {
      if (i % 2 == 0) {
        alice += list.get(i);
      } else {
        bob += list.get(i);
      }
    }
    System.out.println(alice - bob);
  }
}


Measured memory_bytes: 23764
#include <iostream>

using namespace std;

const int maxn = 1e5 + 100;

int s[maxn];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int ans = 0x3f3f3f3f;
    for(int i=0;i+k-1<n;i++){
        ans = min(ans,abs(0-s[i])+s[i+k-1]-s[i]);
    }
    for(int i=k-1;i<n;i++){
        ans = min(ans,abs(0-s[i])+s[i]-s[i-k+1]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import functools
import fractions

def lcm(a, b):
    return a * b // fractions.gcd(a, b)

# xが2で何回割れるか
def div2count(x):
    count=0
    while x%2==0:
        x=x//2
        count+=1
    return count

N,M=map(int,input().split())
A=list(map(int,input().split()))
if len(set(map(div2count,A)))!=1:
    print(0)
    exit()
LCM=functools.reduce(lcm,A)
HLCM=LCM//2
Y=M//HLCM
if Y%2==0:
    print(Y//2)
else:
    print((Y+1)//2)


Measured memory_bytes: 16292
#include <bits/stdc++.h>
#define ll long long
#define nl '\n'
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 1e9+7;
const int N = 2*1e6;

struct mi {
	ll v; explicit operator ll() const { return v; }
	mi() { v = 0; }
	mi(ll _v) { 
		v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD;
	}
	friend bool operator==(const mi& a, const mi& b) { 
		return a.v == b.v; }
	friend bool operator!=(const mi& a, const mi& b) { 
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) { 
		return a.v < b.v; }
   
	mi& operator+=(const mi& m) { 
		if ((v += m.v) >= MOD) v -= MOD; 
		return *this; }
	mi& operator-=(const mi& m) { 
		if ((v -= m.v) < 0) v += MOD; 
		return *this; }
	mi& operator*=(const mi& m) { 
		v = v*m.v%MOD; return *this; }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mi operator-() const { return mi(-v); }
	mi& operator++() { return *this += 1; }
	mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};

const int MX = 2*1e6;
mi fac[MX+5];
mi facInv[MX+5];

void initFac(){
    fac[0] = 1;
    facInv[0] = 1;
    for(int i=1; i<=MX; i++){
        fac[i] = fac[i-1]*i;
        facInv[i] = inv(fac[i]);
    }
}


mi choose(int n, int k){
    if(k<0) return 0;
    if(n<0) return 0;
    if(k>n) return 0;

    mi res = fac[n]*facInv[n-k]*facInv[k];
    return res;
}


int main(){
    AC
    int k;
    string s;
    cin>>k;
    cin>>s;
    initFac();

    int n = k + s.size();
    mi tot = 26;
    mi tmp = 25;
    tot = pow(tot, n);
    tmp = pow(tmp, n);
    mi sum = 0;
    for(int i=0; i<s.size(); i++){
        sum+=choose(n, i)*tmp;
        tmp/=25;
    }
    cout<<tot-sum<<nl;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll K;
    cin >> K;
    vll R(K, 0);
    ll ans = 1;
    ll r = 7 % K;
    ll tr = r;
    R[r] = 1;
    while(tr != 0) {
        ans++;
        r = (r * 10) % K;
        tr = (tr + r) % K;
        if(tr == 0)
            break;
        if(R[tr] > 0) {
            cout << -1 << endl;
            return 0;
        }
        R[tr]++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11164
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
bool desc(pair<int,pair<int,string> > p1, pair<int,pair<int,string> > p2) {
	if(p1.first == p2.first) return p1.second.first < p2.second.first;
	return p1.first > p2.first;
}
int main(){
	int n;
	while(cin >> n, n) {
		vector<pair<int,pair<int,string> > > v;
		int r;
		rep(i,n) {
			pair<int,pair<int,string> > p;
			cin >> p.second.second;
			rep(j,n-1) {
				cin >> r;
				if(r == 0) p.first++;
				if(r == 1) p.second.first++;
			}
			v.push_back(p);
		}
		sort(v.begin(), v.end(), desc);
		rep(i,n) {
			cout << v[i].second.second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>

int mystrcmp(char *s1, char *s2)
{
	int i = 0;
	while (s1[i] == s2[i] && s1[i]) i++;
	int ii = i;
	while (s2[ii]) ii++;
	return ((ii - i) == 1);
}

int main(void)
{
	char s1[11], s2[11];
	scanf("%s", s1);
	scanf("%s", s2);
	if (mystrcmp(s1, s2)) puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
    vector<int> v(3);
    for(int i=0; i<3; i++) cin >> v[i];

    int ma = 0, ma_ind = 0;
    vector<int> ind_o, ind_e;
    for(int i=0; i<3; i++){
        if(v[i]%2 == 0) ind_e.push_back(i);
        else ind_o.push_back(i);
        if(ma < v[i]){
            ma = v[i];
            ma_ind = i;
        }
    }

    int ans = 0;

    if(ind_e.size() == 2){
        v[ind_e[0]]++;
        v[ind_e[1]]++;
        for(int i=0; i<3; i++)ans += (v[ma_ind] - v[i])/2;
        ans++;
    }
    else if(ind_o.size() == 2){
        v[ind_o[0]]++;
        v[ind_o[1]]++;
        for(int i=0; i<3; i++) ans += (v[ma_ind] - v[i])/2;
        ans++;
    }
    else {
        for(int i=0; i<3; i++) ans += (ma - v[i])/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        // ans: 二分木の頂点数の最大値(但し、深さiにA[i]個だけ葉がある)
        long ans = 0;
        
        // ・言い換え
        // 深さiにおける頂点数(count[i])の最大値を考える。
        
        // 下から見る時、count[i]はarray[i]個だけ増やせる
        // -> count[i]のmax = arrayの後ろからの累積和。
        // 上から見る時、頂点数は葉を引いた2倍だけ増やせる
        // <- オーバーフローしそう。 (深さの最大値は10^5)
        // -> 上から見るのを都度、下からのmaxでカットしてやる。
        
        int n = sc.nextInt();
        // array[i]: 深さiの葉の個数
        int[] array = new int[n+1];
        for (int i = 0; i < n+1; i++) {
            array[i] = sc.nextInt();
        }
        
        // sum[i]: 下から見たときのcount[i]の最大値
        long[] sum = new long[n+1];
        sum[n] = array[n];
        for (int i = n-1; i >= 0; i--) {
            sum[i] = sum[i+1] + array[i];
            
        }
        // System.out.println(Arrays.toString(sum));
        
        // count[i]: 深さiにおける頂点数
        long[] count = new long[n+1];
        long now = 1;
        for (int i = 0; i < n+1; i++) {
            // 葉を引いた数の2倍にしたいが、
            // sum[i]が上限ならそれにする
            count[i] = Math.min(sum[i], now);
            
            // 次見るときは葉を引いた数の2倍にする
            now = count[i] - array[i];
            if (now < 0) {
                System.out.println(-1);
                return;
            }
            now *= 2;
        }
        
        for (int i = 0; i < n+1; i++) {
            ans += count[i];
        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 57904
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,i,ans=0;
  double m,sum=0;
  cin >> n;
  cin >> m;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  for(i=0;i<n;i++){
    if(sum/(4*m)<=a.at(i))
      ans++;
  }
  if(m<=ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        int a, b, c, ans;
        Scanner s = new Scanner(System.in);
        a = s.nextInt();
        b = s.nextInt();
        c = s.nextInt();
        ans = 0;
        for (int i=a; i<=b; i++){
            if (c%i==0) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26336
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n;cin>>n;cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(x, n-1) {
        set<char> st1, st2;
        rep(i, n) {
            if (i <= x) {
                st1.insert(s[i]);
            } else {
                st2.insert(s[i]);
            }
        }
        int now = 0;
        for (auto&& c : st1) {
            if (st2.count(c)) now++;
        }
        chmax(ans, now);
    }
    cout << ans << endl;
}

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

using namespace std;

int solve(int n,int r)
{
	if(r==0) return n;
	int p,c; cin>>p>>c;
	int x=solve(n,r-1);
	if(x>n-c)
		x-=(p-1);
	else if(n-c>=x && x>n-p-c+1)
		x+=c;
	return x;
}

int main()
{
	for(int n,r;cin>>n>>r,n|r;)
		cout<<solve(n,r)<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> highten(n);
  for(int i=0;i<n;i++){
    cin >> highten.at(i);
  }
  vector<vector<int>> road(n,vector<int>(0));
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    road.at(a-1).push_back(b);
    road.at(b-1).push_back(a);
  }

  int ans=0;
  for(int i=0;i<n;i++){
    if(road.at(i).size() == 0){ans++;}
    for(int j=0;j<road.at(i).size();j++){
   		if(highten.at(i) <= highten.at(road.at(i).at(j)-1)){break;}
         if(j == road.at(i).size() - 1){ans++;}
    }
  }
    cout << ans << endl;
}

Measured memory_bytes: 8740
S = input()[::-1]

dream_r = 'dream'[::-1] # maerd
dreamer_r = 'dreamer'[::-1] # remaerd
erase_r = 'erase'[::-1] # esare
eraser_r = 'eraser'[::-1] # resare

flag = True
i = 0

while flag:
    if S[i:i+len(dream_r)] == dream_r:
        i += len(dream_r)
    elif S[i:i+len(dreamer_r)] == dreamer_r:
        i += len(dreamer_r)
    elif S[i:i+len(erase_r)] == erase_r:
        i += len(erase_r)
    elif S[i:i+len(eraser_r)] == eraser_r:
        i += len(eraser_r)
    else:
        flag = False

    if i == len(S):
        flag = True
        break

if flag:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A___The_Number_of_Even_Pairs
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = a[0];
            int m = a[1];
            int answer;

            answer = n * (n - 1) / 2 + m * (m - 1) / 2;

            Console.WriteLine(answer);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  double n;
  double a,b;
  cin>>n;
  a=(n*n)*M_PI;
  b=(2*n)*M_PI;
  cout<<fixed<<setprecision(6)<<a<<" ";
  cout<<fixed<<setprecision(6)<<b<<"\n";



  return 0;
}



Measured memory_bytes: 3292
#include<stdio.h>
#include<math.h>
int Sosu(int N){
  int i=3;
if(N==2)return 1;
if(N<2 || N%2==0)return 0;
while(i<=sqrt(N)){
  if(N%i==0)return 0;
  i=i+2;
}
return 1;
}
int main(void){
int N;
int n,i;
int S=0,c=0;
while(1){
scanf("%d",&n);
if(n>=1 && n<=10000)break;
}
for(i=0 ; i<n ; i++){
  while(1){
  scanf("%d",&N);
  if(N>=2 && N<=100000000)break;
  }
  S+=Sosu(N);
}
printf("%d\n",S);
return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

#define N 10000

int main(void){
	vector<bool> isprime(N+1);
	for(int i=0;i<isprime.size();i++) isprime[i]=true;
	int upto = (int)sqrt(isprime.size());
	isprime[1]=false;
	for(int i=2;i<=upto;++i){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<isprime.size();++j) isprime[i*j] = false;
		}
	}
	int n;
	while(cin>>n){
		int c=0;
		for(int i=1;i<=n;++i){
			if(isprime[i]&&isprime[n-i+1])++c;
		}
		cout<<c<<endl;
	}
	return 0;
}

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

const int N = 1e5 + 100;

int main(){

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio( false );
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for( int i = 0; i < n;  i ++ ){
        cout << s[i] << t[i];
    }
}

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

int main() {
  int n, k, p;
  cin >> n;
  cin >> k;
  
  p = int(log2(k)) + 1;
  p = min(p, n);
  
  cout << int(pow(2, p)) + k * (n-p) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{h:usize, w:usize, s:[[String;w]; h]};
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == "snuke" {
                println!("{}{}", ('A' as u8 + j as u8) as char, i+1);
                return ();
            }
        }
    }
}


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

int h[100000],dp[100001],n,ans;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>h[i];
	}
	dp[1]=abs(h[0]-h[1]);
	for (int i=2;i<n;i++){
		dp[i]=min((dp[i-2]+abs(h[i]-h[i-2])),(dp[i-1]+abs(h[i]-h[i-1])));
	}
	cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int main()
{	string c,s;
	vector<string> cc;
	cin>>c>>s;
	int k=0,ff=0;
	REP(i,SZ(c)-SZ(s)+1)
	{
		int f=0;
		REP(j,SZ(s))
		{
			if(c[i+j]!=s[j]&&c[i+j]!='?')
			{
				f=1;break;
			}
		}
		if(f==0)
		{
			cc.PB(c);
			REP(j,SZ(s))
			{
				cc[k][i+j]=s[j];
			}
			REP(j,SZ(cc[k]))
			{
				if(cc[k][j]=='?')cc[k][j]='a';
			}
			k++;
			ff=1;
		}
	}
	if(ff==0)
	{
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	sort(ALL(cc));
	cout<<cc[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    long long ans=0;
    if(a>=k)
    {
        ans=ans+k;
    }
    else if(k>0)
    {
        while(a>0 && k>0)
        {
            ans=ans+1;
            a--;
            k=k-1;
        }
        while(b>0 && k>0)
        {
            ans+=0;
            b--;
            k--;
        }
        while(c>0 && k>0)
        {
            ans+=(-1);
            c--;
            k--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool cmp(int x, int y)
{
    return x > y;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll x, y, a, b, c;
    while (cin >> x >> y >> a >> b >> c)
    {
        ll* p1 = new ll[a + 1];
        ll* p2 = new ll[b + 1];
        ll* p3 = new ll[c + x+y+5];
        for (ll i = 0; i < a; i++)
            cin >> p1[i];
        for (ll i = 0; i < b; i++)
            cin >> p2[i];
        for (ll i = 0; i < c; i++)
            cin >> p3[i];
        sort(p1, p1 + a, cmp);
        sort(p2, p2 + b, cmp);
        ll j = 0;
        for (ll i = c; i < c + x; i++)
        {
            p3[i] = p1[j]; j++;
            //cout << i << " " << p3[i] << '\n';
        }j = 0;
        for (ll i = c+x; i < c + x+y; i++)
        {
            p3[i] = p2[j]; j++;
        }
        sort(p3, p3 + c+x+y, cmp);
        ll ans = 0;
        for (ll i = 0; i < x + y; i++)
            ans += p3[i];
        cout << ans << '\n';
    }
}



Measured memory_bytes: 3968
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int r = 0, l = 0;
    string s;
    cin >> s;
    vector<int> c(s.size(), 0);
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'L'){
            c[i-1] += (r + 1) / 2;
            c[i]   += r / 2;
            r = 0;
        }
        if(s[i] == 'R') r++;
    }
    for(int i = (int)s.size() - 1; i >= 0; i--){
        if(s[i] == 'R'){
            c[i+1] += (l + 1) / 2;
            c[i]   += l / 2;
            l = 0;
        }
        if(s[i] == 'L') l++;
    }
    for(int i = 0; i < (int)s.size(); i++){
        printf("%d ", c[i]);
    }
    cout << endl;
}

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

using namespace std;

int n;
vector <int> ve[210000], vv[210000];
int ans[210000], fa[210000];
set <int> Set[210000];
int S_id;
int tx[210000];

void rev_dfs(int k) {
	if (!Set[S_id].count(k))
		return ;
	Set[S_id].erase(k);
	for (auto y: ve[k])
		if (y != fa[k])
			rev_dfs(y);
}

void remove(int x, int k) {
	S_id = tx[x];
	while (!Set[tx[x]].empty() && *Set[tx[x]].rbegin() > k) {
		rev_dfs(*Set[tx[x]].rbegin());
	}
}

void dfs(int k, int f, int mm) {
	fa[k] = f;
	for (int i = 0; i < (int) ve[k].size(); i++)
		if (ve[k][i] != f)
			dfs(ve[k][i], k, max(mm, k));
	tx[k] = k;
	for (int i = 0; i < (int) ve[k].size(); i++) {
		if (ve[k][i] != f) {
			int x = ve[k][i];
			remove(x, mm);
			vv[k].push_back(Set[tx[x]].size());
		}else {
			vv[k].push_back(0);
		}
	}
	if (k <= mm) {
		Set[tx[k]].insert(k);
		for (int i = 0; i < (int) ve[k].size(); i++) {
			if (ve[k][i] != f) {
				int y = ve[k][i];
				if (Set[tx[y]].size() > Set[tx[k]].size())
					swap(tx[k], tx[y]);
				for (auto kk: Set[tx[y]])
					Set[tx[k]].insert(kk);
				Set[tx[y]].clear();
			}
		}
	}

}

void dfs2(int k, int S) {
	int all = 0;
	for (auto y: vv[k])
		all += y;
	ans[k] = S + all + 1;
	for (int i = 0; i < (int) ve[k].size(); i++)
		if (ve[k][i] != fa[k]) {
			dfs2(ve[k][i], S + 1 + all - vv[k][i]);
		}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ve[x].push_back(y);
		ve[y].push_back(x);
	}
	dfs(1, 0, 0);
	dfs2(1, 0);

	for (int i = 2; i <= n; i++) {
		printf("%d", ans[i] - 1);
		if (i == n)
			printf("\n");
		else
			printf(" ");
	}
}


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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n, k;
    cin >> n >> k;
    bitset<150> b = 0;
    while(k--){
        int d; cin >> d;
        rep(i,d){
            int a; cin >> a;
            b[a] = 1;
        }
    }
    cout << n - b.count() << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define PI acos(-1)
int main(){
double n;
cin>>n;
printf("%.10f %.10f\n",n*n*PI,2*n*PI);

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const ll inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

ll dist(ll x1, ll x2, ll L) {
    if (x1 > x2) swap(x1, x2);
    return min(abs(x1 - x2), L-abs(x1 - x2));
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll L;
    while (cin >> L, L) {
        ll n; cin >> n;
        ll m; cin >> m;
        vector<ll> x(n); x[0] = 0;
        REP(i, n-1) {
            cin >> x[i+1];
        }
        sort( ALL(x) );
        // cout << x << endl;
        ll ans = 0;
        REP(q, m) {
            ll p; cin >> p;
            ll id = lower_bound(x.begin(), x.end(), p) - x.begin();
            ll d = min(dist(p, x[id%n], L), dist(p, x[(id-1+n)%n], L));
            d = min(d, dist(p, x[(id+1)%n], L));
            ans += d;
            // cout << id << " " << ans << endl;
        }
        cout << ans << endl;
    }
}

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

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    ll n, mx = 0;
    ll v[50], c[50];

    cin >> n;

    REP(i, n){
        cin >> v[i];
    }

    REP(i, n){
        cin >> c[i];
    }

    REP(i, n){
        if (v[i] - c[i] > 0){
            mx += v[i] - c[i];
        }
    }

    cout << mx << endl;    

    return 0;
}

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

#define ll long long int


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

	vector<pair<int,string>> p(N),q(N);
	vector<pair<string,int>> r(N);
	set<string> s;

	for(int i=0;i<N;i++){
		cin>>p.at(i).second>>p.at(i).first;
		q.at(i).first=100-p.at(i).first;
		q.at(i).second=p.at(i).second;
		s.insert(p.at(i).second);
	}



	sort(q.begin(),q.end());
    //reverse(p.begin(),p.end());

	for(int i=0;i<N;i++){
		r.at(i).first=q.at(i).second;
		r.at(i).second=q.at(i).first;
	}
	sort(r.begin(),r.end());
 	//reverse(r.begin(),r.end());
	
  	for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(r.at(i).first==p.at(j).second && r.at(i).second==(100-p.at(j).first))
          cout<<j+1<<endl;
      }
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Lmax = 0
Rmin = 10 ** 5
for i in range(M):
  l, r = map(int, input().split())
  Lmax = max(l, Lmax)
  Rmin = min(r, Rmin)
print(max(Rmin - Lmax + 1, 0))

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        // int P = null;

        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }

        
        double minSum = 1000000000;
        Arrays.sort(X); 

        
        for (int j = X[0]; j <= X[N - 1]; j++) {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        }

        System.out.println((int)minSum);
    }
}

Measured memory_bytes: 21844
# ABC052D - Walk and Teleport (ARC067D)
def main():
    # choose A * dist(i, j) or B greedily
    N, A, B = tuple(map(int, input().split()))
    X = tuple(map(int, input().split()))
    ans = sum(min(A * (j - i), B) for i, j in zip(X, X[1:]))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14352
h, n = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]
max_a = max(a for a, _ in lst )
dp = [10**18 for _ in range(h+max_a)]
dp[0] = 0
for i in range(1,h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in lst)
print(min(dp[h:]))

Measured memory_bytes: 3832
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    long long int k;
    int i;
    cin>>k;
        cout<<50<<endl;
        long long int a=k/50;
        long long int amari=k%50;
        long long int d[50];
        
        for(i=0;i<amari;i++){
            d[i]=51-amari;
        }
        for(;i<50;++i){
            d[i]=-amari;
        }
        
        for(int i=0;i<50;i++){
            d[i]+=a+49;
        }
        cout<<d[0];
        for(i=1;i<50;i++){
            cout<<" "<<d[i];
       }
}


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, m;
  cin >> n >> m;
  vector<pair<int, int>> e(m);
  for (auto& x : e) {
    cin >> x.first >> x.second;
    x.first--;
    x.second--;
  }
  vector<int> par(n, -1);
  auto root = [&](int t) {
    if (par[t] < 0) return t;
    for (int i = t;; i = par[i])
      if (par[i] < 0) return par[t] = i;
  };
  vector<ll> ans;
  ll a = (ll)n * (n - 1) / 2;
  for (int i = m; i--;) {
    ans.push_back(a);
    int r1 = root(e[i].first), r2 = root(e[i].second);
    if (r1 != r2) {
      a -= (ll)par[r1] * par[r2];
      if (par[r1] < par[r2]) swap(r1, r2);
      par[r1] += par[r2];
      par[r2] = r1;
    }
  }
  reverse(ans.begin(), ans.end());
  for (auto x : ans) cout << x << endl;
}


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

int ans;
int n,m,k;
int a[200010],b[200010];
long long psa[200010],psb[200010];

int main()
{
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		psa[i]=a[i]+psa[i-1];
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
		psb[i]=b[i]+psb[i-1];
	}
	int t=m;
	for(int i=0;i<=n;i++)
	{
		int cnt;
		if(k>=psa[i])
		{
			cnt=i;
			for(int j=t;j>=0;j--)
			{
				if(psb[j]<=k-psa[i])
				{
					cnt=i+j;
					ans=max(cnt,ans);
					t=j;
					break;
				}
			}
		}
		else
			break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8488
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,d=0,mi=1000001,ma=0;
    scanf("%d %d",&n,&m);
    int l,r;
    for(i=1;i<=m;i++)
    {
        scanf("%d %d",&l,&r);
        if(l>ma)
        {
            ma=l;
        }if(r<mi)
        {
            mi=r;
        }
    }d=mi-ma+1;
    if(d<0)
    {
        d=0;
    }
    printf("%d",d);

}

Measured memory_bytes: 256