akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

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

#define endl "\n"
#define fi first
#define se second
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define pii pair<int, int>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << "\n" << (i->first) <<  ":"  << (i->second);
    return out;
}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

const int N = 2e5 + 100;

int k, n;
int arr[2 * N];

int get(int i, int j) {
    if (j == 0) {
        return arr[i] + (k - arr[n]);
    }
    if (j == n + 1) {
        return arr[1] + (k - arr[n]);
    }
    return abs(arr[i] - arr[j]);
}

int solve() {
    cin >> k >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    arr[0] = arr[n];
    arr[n + 1] = arr[0];
    int ans = k;
    for (int i = 1; i <= n; i++) {
        int diff = get(i, i - 1);
        int d2 = get(i, i + 1);
        ans = min(ans, k - max(diff, d2));
    }
    cout << ans << endl;

}

int32_t main(){ _
    int t;
    // cin >> t;
    t = 1;
    while (t--) solve();
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	int MAX = 2000000;
	int H = 0;
	int A[] = new int[MAX + 1];
	int INF = -1;

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String line = scanner.next();
			if (line.equals("end"))
				break;
			else if (line.equals("insert")) {
				insert(scanner.nextInt());
			} else {
				System.out.println(extract());
			}
		}
	}

	private int extract() {
		int maxv = A[1];
		A[1] = A[H--];
		maxHeapify(1);
		return maxv;
	}

	private void maxHeapify(int i) {
		int l = left(i);
		int r = right(i);
		int largest = -1;
		if (l <= H && A[l] > A[i])
			largest = l;
		else
			largest = i;
		if (r <= H && A[r] > A[largest])
			largest = r;
		if (i != largest) {
			swap(i, largest);
			maxHeapify(largest);
		}
	}

	private void insert(int key) {
		H++;
		A[H] = INF;
		inceraseKey(H, key);
	}

	private void inceraseKey(int i, int key) {
		if (A[H] > 0)
			return;
		A[H] = key;
		while (i > 1 && A[i] > A[parent(i)]) {
			swap(i, parent(i));
			i = parent(i);
		}
	}

	private void swap(int i, int parent) {
		int t = A[i];
		A[i] = A[parent];
		A[parent] = t;
	}

	int parent(int i) {
		return i / 2;
	}

	int left(int i) {
		return i * 2;
	}

	int right(int i) {
		return i * 2 + 1;
	}
}

Measured memory_bytes: 547564
n = int(input())
S = [input() for _ in range(n)]
ac = 0
wa = 0
tle = 0
re = 0
for s in S:
  if s == "AC":
    ac += 1
  elif s == "WA":
    wa += 1
  elif s == "TLE":
    tle += 1
  else:
    re += 1 

print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)

Measured memory_bytes: 16248
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		double r = input();

		System.out.print(String.format("%.5f", r * r * Math.PI));
		System.out.print(" ");
		System.out.print(String.format("%.5f", 2.0 * r * Math.PI));

		close();

	}

	public static double input() {

		return scanner.nextDouble();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 28416
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a <= 0 && b >= 0 {
		fmt.Println("Zero")
	} else if a > 0 || (b-a+1)%2 == 0 {
		fmt.Println("Positive")
	} else {
		fmt.Println("Negative")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <zconf.h>

// 设dp[i][j] 表示 “只考虑前 i 个物品的情况下，总价值是 j 所需的最小容量”。
// dp[i][j] = min(w_s[i] + dp[i-1][j-v_s[i]], dp[i-1][j])
int main() {
    int N,W;
    std::cin >> N >> W;
    std::vector<int> w_s(N+1, 0);
    std::vector<int> v_s(N+1, 0);

    for (int i=1;i<=N;i++) {
        std::cin >> w_s[i] >> v_s[i];
    }
    int bound = N*1000;
    std::vector<std::vector<long long>> dp;
    dp.resize(N+1);
    for (int i=0;i<=N;i++) {
        dp[i].resize(bound);
    }

    for(int v = 0;v<=bound;v++) {
        if(v == 0)  {
            dp[0][v] = 0;
        } else {
            dp[0][v] = INT_MAX;
        }
    }

    for (int i=1;i<=N;i++) {
        for (int j=0;j<=bound;j++) {
            if (j >= v_s[i]) {
                dp[i][j] = std::min(w_s[i] + dp[i-1][j-v_s[i]], dp[i-1][j]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
            // std::cout << i << ' ' << j << " " << dp[i][j] << std::endl;
        }
    }
    int res = 0;
    for(int i = 0;i<=bound;i++)
        if(dp[N][i] <= W)
            res = i;
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 79488
#include<iostream>
using namespace std;
int main(){
     int A,B,a,b;
     cin>>a>>b;
     A=a+b;
     B=a*b;
     if(A==15)cout<<"+"<<endl;
     else if(B==15)cout<<"*"<<endl;
     else cout<<"x"<<endl;
     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, ans = 0;
    cin >> n;
    stack <ll> s;
    vll a(n), l(n, -1);
    for(i = 0; i < n; i++)
        cin >> a[i];
    for(i = 0; i < n;)
    {
        ll j = i + 1;
        while(j < n)
        {
            if(a[j] > a[j - 1])
                break;
            j++;
        }
        ans = max(ans, j - i - 1);
        i = j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll X; cin >> X;
	for (ll i = 0; i < 10000; ++i) {
		for (ll j = 0; j < 10000; ++j) {
			ll i5 = i * i * i * i * i;
			ll j5 = j * j * j * j * j;
			if (i5 + j5 == X) {
				cout << i << " " << -j << endl;
				return;
			}
			if (i5 - j5 == X) {
				cout << i << " " << j << endl;
				return;
			}
		}
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll a,b,c,k,ans=0;
    cin >> a >> b >> c >> k;
    ans += min(a,k);
    k -= min(a,k);
    k -= min(b,k);
    ans -= k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
let () =
  let s = read_line () in
  let word = read_line () in
  let is_contanin =
    let len_s = String.length s in
    let len_w = String.length word in
    let ling = s ^ s in 
    let rec iter i =
      if i=len_s then false
      else (if (String.sub ling i len_w) = word then true
            else iter (i+1))
    in iter 0
  in
  print_endline (if is_contanin then "Yes" else "No")

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

int main(){
    int N;
    cin >> N;
    vector<int> ans(N + 1, 0);
    for (int i = 1; i <= 100; i++){
        for (int j = 1; j <= 100; j++){
            for (int k = 1; k <= 100; k++){
                int sum = i * i + j * j + k * k + i * j + j * k + k * i;
                if (sum <= N){
                    ans[sum]++;
                }
            }
        }
    }
    for (int i = 1; i <= N; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define fi(n) for(int i=0;i<n;i++)
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	string x,y;
	cin>>x;
	cin>>y;
	int m=x.length();
	int n=y.length();
	vector<char>v;
	int dp[m+1][n+1];
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(i==0||j==0)
			dp[i][j]=0;
			else if(x[i-1]==y[j-1])
			dp[i][j] = 1+dp[i-1][j-1];
			else
			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=m;int j=n;
	while(i>0 &&j>0){
		if(x[i-1]==y[j-1])
		{
			v.push_back(x[i-1]);
			i--;j--;
		}
		else if(dp[i][j-1]>dp[i-1][j])
		j--;
		else
		i--;
	}
	reverse(v.begin(),v.end());
	for(auto x:v)
	cout<<x;
	return 0;
}


Measured memory_bytes: 35456
#include <iostream>


const int SMAX = 200000;

void input_data(int *src, int *n_src, int *dst, int *n_dst)
{
  std::cin >> *n_src;
  for (int i =0; i < *n_src; i++)
    std::cin >> src[i];

  std::cin >> *n_dst;
  for (int i=0; i<*n_dst; i++)
    std::cin >> dst[i];

  return;
}

//line search
//配列を探索　見つかったらindex, 見つからなかったら-1を返す。
int bin_search(int n_src, int *src, int dst)
{
  int fr=0, bk=n_src-1;
  int center;
  if (dst < src[fr] || src[bk] < dst) return -1; 
  
  if (dst == src[fr] ) return fr;
  if (dst == src[bk]) return bk;
  while(true){
    center = (fr+bk +1)/2;

    if (src[ center] == dst)
      return center;

    if (fr == center || center == bk)
      return -1;
    if (src[ center ] > dst )
      bk = center;
    else if (src[ center ] < dst )
      fr = center;
  }

  return -1;
}


int main()
{
  int n_src, src[SMAX];
  int n_dst, dst[SMAX];

  input_data(src, &n_src, dst, &n_dst);

  //dstの配列を一個ずつsrc内に無いか、を確認する
  bool flag[n_dst];
  for (int i=0; i<n_dst; i++)
  {
    flag[i] = false;
    if (bin_search(n_src, src, dst[i]) != -1) 
      flag[i] = true;
  }
  
  int count=0;
  for (int i=0; i<n_dst; i++)
    if (flag[i]) count++;
  std::cout << count <<std::endl;
}



Measured memory_bytes: 3684
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////

ll min(ll a,ll b){
    if(a<b)return a;else return b;
}
ll dis(ll a,ll b,ll c){
    ll d=abs(b-a),e=abs(c-b),f=abs(c-a);
    if(d<e)d=e;
    if(d<f)d=f;
    return d;
}


int main(){
    ll h,w;cin>>h>>w;
    ll ans=inf;
    if(w%3==0)ans=0;
    else ans=min(h,ans);
    if(h%3==0)ans=0;
    else ans=min(w,ans);
    
    ll i=w/3;
    for(int j=i;j<=i+1;j++){
        ll a,b,c;
        a=j*h;
        b=(w-j)*(h/2);
        c=w*h-a-b;
        ans=min(ans,dis(a,b,c));
    }
    i=h/3;
    for(int j=i;j<=i+1;j++){
        ll a,b,c;
        a=j*w;
        b=(h-j)*(w/2);
        c=w*h-a-b;
        ans=min(ans,dis(a,b,c));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long n = long.Parse(input[0]);
		long w = long.Parse(input[1]);
    long[,] dp = new long[n+1,w+1];//n個まで見たとき、wを超えない価値の最大値

    long[,] vertexes = new long[n,2];
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
    }

    for(long i = 0; i <= n; i++)
    {
      for(long j = 0; j <= w; j++)
      {
        if(j-1 >= 0) dp[i,j] = Math.Max(dp[i,j], dp[i,j-1]);
        if(i-1 >= 0)
        {
          dp[i,j] = Math.Max(dp[i,j], dp[i-1,j]);
          if(j-vertexes[i-1,1] >= 0) 
          {
            dp[i,j] = Math.Max(dp[i,j], dp[i-1, j-vertexes[i-1,1]] + vertexes[i-1,0]);
            //Console.WriteLine("a"+dp[i-1, j-vertexes[i-1,1]] + vertexes[i-1,0]);
          }
        }
        //Console.WriteLine(i+" "+j+" "+dp[i,j]);
      }
    }

		Console.WriteLine(dp[n,w]);
	}
}



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

const int INF = pow(2,30);
const int MAX_N = pow(10,5);

int dp[MAX_N];

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

  fill_n(dp,MAX_N,INF); dp[0] = 0;
  for (int i=1; i<N; i++) {
    for (int j=1; j<=K; j++) {
      if (i>=j) dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  // for (int i=0; i<N; i++) cout << dp[i] << endl;
   cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1148
from collections import Counter


N = int(input())
M = [tuple(map(int, input().split())) for _ in range(N)]
Map = []
if N == 1:
    print(1)
    exit()
for i in range(N):
    x1, y1 = M[i]
    for j in range(N):
        if i == j:
            continue
        x2, y2 = M[j]
        Map.append((x2 - x1, y2 - y1))
MapC = Counter(Map)
print(N - MapC.most_common(1)[0][1])





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

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

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n;
struct uzi
{
	LL a,b,h;
}p[N];
LL ans;
LL c(int x,int y){
	int sta=1;
	int ch=0;
	LL H =0ll+abs(p[1].a-x)+abs(p[1].b-y)+p[1].h;
	if(p[1].h)ch=1;
	for(int i=2;i<=n;i++){
		if(p[i].h){
			if(ch){
				if(max(H-abs(x-p[i].a)-abs(y-p[i].b),0ll)!=p[i].h)return 0;
			}else{
				if(p[i].h+abs(x-p[i].a)+abs(y-p[i].b)<=H){
					H=p[i].h+abs(x-p[i].a)+abs(y-p[i].b);
					ch=1;
				}else return 0;
			}
		}else{
			LL mid=abs(p[i].a-x)+abs(p[i].b-y);
			if(ch){
				if(mid<H)return 0;
			}else{
				H =min(H,mid);
			}
		}
	}
	return ans=H,1;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i].a>>p[i].b>>p[i].h;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			if(c(i,j)&&ans>=1)return cout<<i<<' '<<j<<' '<<ans<<endl,0;
		}
	}	
	return 0;
}

Measured memory_bytes: 256
import math
import collections
import bisect
N=int(input())
# N,M=map(int,input().split())
# S=[[]for i in range(N)]
# # for i in range(Q):
A=list(map(int,input().split()))
# #     S[i]=a
L=[i-A[i] for i in range(N)]
R=[i+A[i] for i in range(N)]
L.sort()
R.sort()
ans=0
for i in R:
    ans+=-bisect.bisect_left(L,i)+bisect.bisect_right(L,i)
print(ans)

Measured memory_bytes: 115788
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n,i;
	while(cin>>n>>i){
		cout<<n-i+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int R;cin>>R;
	double ans = 2.0 * 3.141592653589793 * R;
	cout.precision(10);
	cout<<fixed<<ans<<endl;
}

Measured memory_bytes: 3788
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if(a % b == 0){
				System.out.println("-1");
			}
			else{
				System.out.println(a);
			}
			
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


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

using ll = long long;

const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];

void solve() {
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC\n";
    }else{
        cout << "ABC\n";
    }
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}// smf

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	int n,m,c;
	cin>>n>>m>>c;
	VI b;
	FOR(i,0,m){
		int x;
		cin>>x;
		b.PB(x);
	}
	int a[n][m];
	FOR(i,0,n){
		FOR(j,0,m){
			cin>>a[i][j];
		}
	}
	int64 ans=0LL;
	FOR(i,0,n){
		int64 t=c;
		FOR(j,0,m){
			t+=a[i][j]*b[j];
		}
		if(t>0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int i;
	bool hasc = false, res = false;
	for (i = 0; i < s.length(); i++)
	{
		if (hasc)
		{
			if (s[i] == 'F')
				res = true;
		}
		else
		{
			if (s[i] == 'C')
				hasc = true;
		}
	}
	if (res)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<char> moji(W);
    for(int i = 0; i < moji.size() + 2; i++){
        cout << "#";
    }
    cout << endl;
    for(int i = 0; i < H; i++){
      cout << "#";
      for(int j = 0; j < moji.size(); j++){
          cin >> moji.at(j);
          cout << moji.at(j);
      }
      cout << "#" << endl;
    }
    for(int i = 0; i < W + 2; i++){
        cout << "#";
    }
    cout << endl;
}

Measured memory_bytes: 256
# ２点(a, b) (c, d)を通る直線の傾きと切片を返す
def func(a, b, c, d):
    k = (d - b) / (c - a)
    h = d - k * c
    return k, h


# ２点と通る直線のf(x)を返す
def fx(a, b, c, d, x):
    k, h = func(a, b, c, d)
    return k * x + h


def main():
    import sys
    for dataset in sys.stdin:
        ans = 'NO'
        try :
            a, b, c, d, e, f, px, py = map(float, dataset.split())
        except:
            break
        T = [(a, b), (c, d), (e, f)]
        T.sort(key=lambda x: (x[0], x[1]))
        a, b, c, d, e, f = T[0][0], T[0][1], T[1][0], T[1][1], T[2][0], T[2][1]
        # 共通なxを持つ２点が存在するか判定し、する場合
        if a == c:
            if  a < px and fx(a, b, e, f, px) < py and fx(c, d, e, f, px) > py:
                ans = 'YES'
        elif c == e:
            if px < e and fx(a, b, c, d, px) < py and fx(a, b, e, f, px) > py:
                ans = 'YES'
        else:  # ３点において共通のxを持たない場合
            if fx(a, b, e, f, c) < d:  # 中間点が残り２点を通る直線より上にあるケース
                if fx(a, b, c, d, px) > py and fx(c, d, e, f, px) > py and fx(a, b, e, f, px) < py:
                    ans = 'YES'
            else:
                if fx(a, b, c, d, px) < py and fx(c, d, e, f, px) < py and fx(a, b, e, f, px) > py:
                    ans = 'YES'

        print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}



signed main () {
    int n;int d;cin >>n>>d;
    vector<pair<int,int>> a(n);int cnt=0;
    rep(i,n){
       int p,q;cin >>p>>q;
       if(p*p+q*q<=d*d)cnt++;
    }
    cout <<cnt<<endl;
}





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

// 1 つの証言を表す構造体
using pint = pair<int, int>; // 「人」と「0 or 1」

// 入力
int N;
vector<vector<pint>> v;

// 整数 bit に対応する「決め打ち」が整合しているかを判定
bool judge(int bit) {

    // i 人目の証言を検証する
    for (int i = 0; i < N; ++i) {

        // i 人目が「不親切」だったら、証言はすべて無意味
        if (!(bit & (1 << i))) continue;

        // それぞれ確認
        for (pint xy : v[i]) {
            int x = xy.first; // x が
            int y = xy.second; // y = 1: 正直、y = 0: 不親切

            // y = 1 なのに「不親切」だったらダメ
            if (y == 1 && !(bit & (1 << x))) return false;

            // y = 0 なのに「正直者」だったらダメ
            if (y == 0 && (bit & (1 << x))) return false;
        }
    }
    return true;
}


int main() {
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i) {
        int A; cin >> A;
        v[i].resize(A);
        for (int j = 0; j < A; ++j) {
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first; // 0-indexed に
        }
    }

    int res = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {

        // 矛盾 check
        if (judge(bit)) {

            // bit に含まれる人数を数える
            int count = 0;
            for (int i = 0; i < N; ++i) {
                if (bit & (1 << i)) ++count;
            }
            res = max(res, count);
        }
    }

    cout << res << endl;
}

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


def solve(N: int):
    p = N % 1000
    if p > 0:
        p = 1000 - p
    print(p)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
def win_cou(n,m):
    cou = 0
    while m > n:
        n = n * 2
        cou = cou + 1
    return cou*(-1)



Input = input().split()
N = int(Input[0])
K = int(Input[1])
rate = 0

for i in range(N):
    rate = rate + (2 ** win_cou(i+1,K)) / N

print(rate)

Measured memory_bytes: 3060
N = int(input())
S = input()
ans = 0
for i in range(1,N-1):
    lis1 = [0]*26
    lis2 = [0]*26
    for j,s in enumerate(S):
        if j<i:
            lis1[ord(s)-97] = 1
        else:
            lis2[ord(s)-97] = 1
    ans = max(ans,sum([lis1[i]*lis2[i] for i in range(26)]))
print(ans)

Measured memory_bytes: 3064
from sys import stdin
import numpy as np
from operator import itemgetter

#N = int(stdin.readline().rstrip().split()[0])
H, W = [int(x) for x in stdin.readline().rstrip().split()]
#A = [int(x) for x in stdin.readline().rstrip().split()]

MOD = 10**9 + 7
H_2 = H//2
W_2 = W//2

ans = W*H_2
if H%2 != 0:
  ans += W_2
  if W%2 != 0:
    ans += 1

if H==1 or W==1:
  ans =1

print(ans)


Measured memory_bytes: 20640
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var A = new int[n];
            var B = new int[n];
            var C = new int[n-1];
            var In1 = Console.ReadLine().Split(' ');
            for(int i=0; i < n; i++)
            {
                A[i] = int.Parse(In1[i]);
            }
            var In2 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                B[i] = int.Parse(In2[i]);
            }
            var In3 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n-1; i++)
            {
                C[i] = int.Parse(In3[i]);
            }
            long sum = 0;
            int bef = -100;
            for(int i=0; i < n; i++)
            {
                sum += B[A[i] - 1];
                if (A[i] - 1 == bef) sum += C[bef-1];
                bef = A[i];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 27348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> C(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    C.at(a - 1)++;
    C.at(b - 1)++;
  }
  
  for (int i=0; i<N; i++) 
    cout << C.at(i) << endl;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map {|item| item.to_i }
cardAList = gets.chomp.split(" ").map {|item| item.to_i }.sort!
bcList = []
m.times do |j|
    bcList[j] = gets.chomp.split(" ").map {|item| item.to_i }
end
bcList.sort!{|a, b| b[1] <=> a[1]}

replaced_index = 0
replaced_index2 = 0
bcList.each do |bc|
    b = bc[0]
    c = bc[1]
    b.times do |i|
        index = i + replaced_index
        if cardAList.length <= index
            break
        end
        if cardAList[index] < c
            cardAList[index] = c
            replaced_index2 = index+1
        else
            break
        end
    end
    if replaced_index2 > replaced_index
        replaced_index = replaced_index2
    end
end

sum = 0
cardAList.each do |a|
    sum += a
end
puts sum

Measured memory_bytes: 19064
n = gets.to_i
i = 1

loop do
  x = i
  if (x % 3 == 0) then
    printf " %d", i
  else
    loop do
      if (x % 10 == 3 ) then
        printf " %d", i
        break
      end
      x /= 10
      break if x == 0
    end
  end
  i += 1
  break if (i > n)
end

puts


Measured memory_bytes: 6872
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXDIM=500000;
const int MOD=998244353;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
void dec(int &a,int b) { inc(a,MOD-b); }




int h,w;


int inv[MAXDIM+1];
int fac[MAXDIM+1];
int ifac[MAXDIM+1];

int freerowways[MAXDIM+1];
int freecolways[MAXDIM+1];

int choose(int n,int k) { assert(0<=n&&n<=max(h,w)); if(k<0||k>n) return 0; return (ll)fac[n]*ifac[k]%MOD*ifac[n-k]%MOD; }




int solve() {
	inv[1]=1; FORE(i,2,MAXDIM) inv[i]=(ll)(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1; FORE(i,1,MAXDIM) fac[i]=(ll)fac[i-1]*i%MOD;
	ifac[0]=1; FORE(i,1,MAXDIM) ifac[i]=(ll)ifac[i-1]*inv[i]%MOD;

	freerowways[0]=1; FORE(i,1,h) freerowways[i]=(ll)freerowways[i-1]*(w+1)%MOD;
	freecolways[0]=1; FORE(i,1,w) freecolways[i]=(ll)freecolways[i-1]*(h+1)%MOD;

	int ret=0;
	REPE(nfixed,min(h,w)) {
		int ways=(ll)choose(w,nfixed)*choose(h,nfixed)%MOD*freerowways[h-nfixed]%MOD*freecolways[w-nfixed]%MOD*fac[nfixed]%MOD;
		if(nfixed%2==0) inc(ret,ways); else dec(ret,ways);
	}
	return ret;
}

void run() {
	scanf("%d%d",&h,&w);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 9984
import queue
n, m = map(int, input().split())
route = [[] for _ in range(n)]
vals = []
for _ in range(m):
    a, b = map(int, input().split())
    route[a-1].append(b-1)
    route[b-1].append(a-1)
    vals.append([a-1, b-1])
ans = m
for i in range(m):
    route2 = set()
    q = queue.Queue()
    q.put(0)
    route[vals[i][0]].remove(vals[i][1])
    route[vals[i][1]].remove(vals[i][0])
    while not q.empty():
        a = q.get()
        if not a in route2:
            route2.add(a)
            for j in route[a]:
                q.put(j)
        if len(route2) == n:
            ans -= 1
            break
    route[vals[i][0]].append(vals[i][1])
    route[vals[i][1]].append(vals[i][0])
print(ans)
        


Measured memory_bytes: 9564
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int b,n;
char s[500010];
LL ans;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	b=0;
	FOR(i,1,n)
		if (s[i]=='B') ++b;
		else ans+=b;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define pii pair<int,int>
#define dbg(x) cout << (#x) << " is " << (x) << '\n' 
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

void solve()
{
   int n;
   cin >> n;
   int a[n+1],tot=0;
   f(i,n+1)
    cin >> a[i],tot+=a[i];
   int flg=0;
   int len=0,ans=0;
  
   f(i,n+1)
   {
       if(i==0)
        len=(1-a[i]);
       else
       {
         tot-=a[i];
         len=min(tot,(2*len)-a[i]);
       } 
       ans+=(len+a[i]);
      //  dbg(len);
       if(len<0)
       {
           cout << "-1\n";return;
       }
   }
   cout << ans << '\n';
    return;
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 4436
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
int f[N2];
int space;
string path;

bool operator < (const Puzzle &p) const{
for(int i = 0; i < N2; i++){
if(f[i] == p.f[i]) continue;
return f[i] > p.f[i];
}
return false;
}
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
for(int i = 0; i < N2; i++)
if(p.f[i] != (i + 1)) return false;
return true;
}

string bfs(Puzzle s){
queue<Puzzle> Q;
map<Puzzle, bool> V;
Puzzle u, v;
s.path = "";
Q.push(s);
V[s] = true;

while(!Q.empty()){
u = Q.front(); Q.pop();
if(isTarget(u)) return u.path;
int sx = u.space / N;
int sy = u.space % N;
for(int r = 0; r < 4; r++){
int tx = sx + dx[r];
int ty = sy + dy[r];
if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
v = u;
swap(v.f[u.space], v.f[tx * N + ty]);
v.space = tx * N + ty;
if(!V[v]){
V[v] = true;
v.path += dir[r];
Q.push(v);
}
}
}
return "unsolvable";
}

int main(){
Puzzle in;
for(int i = 0; i < N2; i++){
cin >> in.f[i];
if(in.f[i] == 0){
in.f[i] = N2;
in.space = i;
}
}
string ans = bfs(in);
cout << ans.size() << endl;

return 0;
}

Measured memory_bytes: 30580
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

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

  std::vector<std::pair<int, int>> rl(n);
  for (size_t i = 0; i < n; ++i) {
    int x, l;
    scanf("%d %d", &x, &l);
    rl[i] = {x+l, x-l};
  }
  std::sort(rl.begin(), rl.end());

  int res = 0;
  int last = -1e9-1;
  for (auto const& p: rl) {
    int l, r;
    std::tie(r, l) = p;
    if (last <= l) {
      last = r;
      ++res;
    }
  }

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


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i64 n; cin >> n;
    vl a(n); rep(i,n) cin >> a[i];

    i64 sum = 0;
    rep(i,n) sum += a[i]-1;
    cout << sum << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int X;
  cin>>X;

  Int ans = -1;
  if(X <= 599) ans = 8;
  else if(X <= 799) ans = 7;
  else if(X <= 999) ans = 6;
  else if(X <= 1199) ans = 5;
  else if(X <= 1399) ans = 4;
  else if(X <= 1599) ans = 3;
  else if(X <= 1799) ans = 2;
  else if(X <= 1999) ans = 1;

  cout<<ans<<endl;

  return 0;
}


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

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

// code starts

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  rep(i,n) cin >> a[i];
  int xors = 0;
  rep(i,n) xors = xors^a[i];
  rep(i,n)
  {
    if(i != 0) cout << ' ';
    int tmp = a[i]^xors;
    cout << tmp;
  }
  cout << endl;
}


Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
using namespace std;


int main(){
	string S;
	cin >> S;
	int len = S.size();
	vector<int> A(len);
	long long sum = 0;
	for(int i=0;i<len;i++){
		A[i] = S[i] - '0';
	}
	long long temp = A[0];
	for(int i=0;i<(1<<(len-1));i++){//1をlen個分左シフトした回解繰り返す
		for(int shift=0;shift<len-1;shift++){
			if(i & (1 << shift)){//右からi-1番目に+が入っていた場合
				sum += temp;
				temp = A[shift+1];
			}else{
				temp = 10 * temp + A[shift+1];
			}
		}
		sum += temp;
		temp = A[0];
	}

	cout << sum << endl;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????§????????????????????????
		 Scanner sc = new Scanner(System.in);
		 //??£?¨?
		int i =1;
		
		//???????????§??????
		 while(i !=0){
			int x = sc.nextInt();
			 //?????¶??? ??????0?????´?????????
			 if(x == 0){
				 break;
			 }
			System.out.println("Case " + i + ": " + x);
			 i++;
		 }
	}
}

Measured memory_bytes: 41216
#include<bits/stdc++.h>
using namespace std;
int ara[500];
int main()
{
    int n,mn,sum,p;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>ara[i];
    sort(ara,ara+n);
    mn=1e12;
    for(int i=ara[0];i<=ara[n-1];i++)
    {
        sum=0;
        for(int j=0;j<n;j++)
        {
            p=(ara[j]-i);
            sum+=(p*p);
        }
        if(sum<mn)
            mn=sum;
    }
    cout<<mn<<endl;

    return 0;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
que = []
for i in a:
    heapq.heappush(que, -i)
for i in range(m):
    s = heapq.heappop(que)
    s = -s // 2
    heapq.heappush(que, -s)
print(-1 * sum(que))


Measured memory_bytes: 64792
n;
char s[2<<17];
cnt[2<<17];
main()
{
  scanf("%d\n%s",&n,s);
  for(int i=n;i--;)
  {
    cnt[i]=cnt[i+1]+(s[i]=='.');
  }
  int ret=0;
  int ans=cnt[0];
  for(int i=0;i<n;i++)
  {
    ret+=s[i]=='#';
    ans=fmin(ans,ret+cnt[i+1]);
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(2, 0));
    for (int i = 0; i < n; ++i) {
        cin >> v[i][0];
        v[i][1] = i;
    }

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

    vector<int> ans(n);
    int max = -1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (v[j][1] == i) continue;
            if (v[j][0] > max) {
                ans[i] = v[j][0];
                break;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 13312
#include<stdio.h>

int main(){
  int n,a[100],b[10000]={},cnt=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    b[a[i]]=1;
  }
  for(int i=1;i<n;i++){
    if(a[i]==a[i-1]){
      cnt++;
      for(int j=1;j<=10000;j++)
        if(b[j]==0){
          a[i]=j;
          b[j]=1;
          break;
        }
    }
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 256
import numpy as np
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
set_p = set(p)

if X not in set_p:
    print(X)
else:
    tmp = set(range(0, 102))
    notinp = np.array(list(tmp - set_p))
    t = np.abs(np.array(notinp) - X)
    argmin = t.argmin()
    print(notinp[notinp == notinp[argmin]].min())

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

using namespace std;
using ll = long long;
const int maxn = 1e6;
ll dp[maxn], sum[maxn];

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int> (n));
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for (int mask = 0; mask < (1 << n); mask++){
        for (int i = 0; i < n; i++){
            if ((1 << i) & mask){
                for (int j = i + 1; j < n; j++){
                    if ((1 << j) & mask){
                        sum[mask] += a[i][j];
                    }
                }
            }
        }
    }
    for (int mask = 0; mask < (1 << n); mask++){
        dp[mask] = sum[mask];
        for (int subset_mask = mask; subset_mask > 0; subset_mask = (subset_mask - 1) & mask){
            dp[mask] = max(dp[mask], dp[subset_mask] + dp[mask - subset_mask]);
        }
    }
    cout << dp[(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 4864
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/xpressive/xpressive_static.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;
using namespace boost::xpressive;

int main() {
  string S;
  cin >> S;

  S.pop_back();
  boost::xpressive::smatch m;
  const sregex re = bos >> (s1 = +lower) >> s1;
  regex_search(S, m, re);
  cout << m.str().length() << endl;
  return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
//https://qiita.com/drken/items/7c6ff2aa4d8fce1c9361#bit-dp
const int INF = 100000000;
int V, E;
int dp[(1<<15)+1][15][15];
int dist[15][15];

//int res = INF;
int rec(int bit, int v,int start) {
	if (dp[bit][v][start] != -1) {
		return dp[bit][v][start];
	}
	
	if (bit == 1<<v) {
		if (dist[start][v] == -1)return  INF;
		return dp[bit][v][v] = dist[start][v];
	}
	int res = INF;
	int prev_bit = bit & ~(1 << v);
	for (int u = 0; u < V; u++) {
		if (!(prev_bit&(1 << u)))continue;
		if ( (dist[u][v] != -1)&&res > rec(prev_bit, u,start) + dist[u][v]) {
			//cout << res << endl;
			res = rec(prev_bit, u,start) + dist[u][v];
		}
	}
	return dp[bit][v][start] = res;
}
int main() {
	scanf("%d%d", &V, &E);
	memset(dist, -1, sizeof(dist));
	memset(dp, -1, sizeof(dp));		
	for (int i = 0; i < E; i++) {
		int s, t, d;
		scanf("%d%d%d", &s, &t, &d);
		dist[s][t] = d;
	}
	int result = INF;
	for (int v = 0; v < V; ++v) {
		if (result > rec((1 << V) - 1, v,v)) {
			result = rec((1 << V) - 1, v,v);
		}
	}
	if (result == INF)printf("%d\n", -1);
	else //cout << result << endl;
	 printf("%d\n", result);
}
//dp[1000][v]=0
//dp[111][v]


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

int main() {
  int n;
  cin >> n;
  int nab=0,nea=0,nfb=0,eafb=0;
  for(int i=0;i<n;i++) {
    string s;
    cin >> s;
    if(s[0]=='B'&&s[s.size()-1]!='A') nfb++;
    if(s[0]!='B'&&s[s.size()-1]=='A') nea++;
    if(s[0]=='B'&&s[s.size()-1]=='A') eafb++;
    for(int j=0;j<s.size()-1;j++) {
      if(s.substr(j,2)=="AB") nab++;
    }
  }
  int temp;
  if(nea+nfb==0) {
    temp=max(eafb-1,0);
  }
  else {
    temp=eafb+min(nea,nfb);
  }
  cout << nab + temp << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int k=Integer.parseInt(sc.next());
int ans=k;
for(int i=0;i<n-1;i++){
ans*=k-1;
}
System.out.println(ans);
}
}

Measured memory_bytes: 21844