akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

const string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";

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

    string s;
    cin >> s;
    
    int m = s.size();
    string t = s;

    rep(i,m) {
        t[i] = alpha[s[i]-'A'+n];
    }
    cout << t << endl;

    return 0;
} /*atcoder*/



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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int a;
  cin >> a;

  rep(i, 25) {
    rep(j, 17) {
      int b = 4 * i + 7 * j;
      if (a == b) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}

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

int main(){
  int N,D;
  cin >> N >> D;
  vector<vector<double>> X(N,vector<double>(D));
  int count = 0;
  for(int i = 0;i < N;i++){
    for(int j = 0;j < D;j++){
      cin >> X[i][j];
    }
  }

  for(int i = 0;i < N - 1;i++){
    for(int j = i + 1;j < N;j++){
      double diff = 0.0;
      for(int k = 0;k < D;k++){
        diff = diff + pow((X[j][k] - X[i][k]), 2.0);
      }
      double diff_double = pow(diff, 0.5);


      
      int diff_int = diff_double;

      if(diff_double == diff_int)
        count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var n, time, ans int
	fmt.Scanf("%d %d", &n, &time)
	c := make([]int, n)
	t := make([]int, n)
	ans = 1001
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d", &c[i], &t[i])
		if t[i] <= time && c[i] < ans {
			ans = c[i]
		}
	}
	if ans == 1001 {
		fmt.Println("TLE")
	} else {
		fmt.Println(ans)
	}
}

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

long long euclidean_gcd(long long a, long long b) {
  if(a < b) return euclidean_gcd(b, a);

  long long r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


long long prime_factorization_unique(long long num) {
    long long res = 1;
    for (long long p=2; p * p < num; p++) {
        if (num % p != 0) continue;
        while (num % p == 0) num/=p;
        res += 1;
    }
    if (num != 1) res += 1;
    return res;
}


int main() {
    long long A, B;
    cin >> A >> B;
    long long gcd = euclidean_gcd(A, B);
    long long res = prime_factorization_unique(gcd);
 
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int H = 1, W = 1, i, j;
    while (H && W)
    {   
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
        {
            break;
        }
        for (i = 0; i < H; i++)
        {
            for (j = 0; j < W; j++)
            {
	            if (i == 0 || i == H-1 || j == 0 || j == W-1)
                {
                    printf("#");
                }
	            else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		int[] dp = new int[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(
					dp[i - 1] + Math.abs(h[i] - h[i - 1]),
					dp[i - 2] + Math.abs(h[i] - h[i - 2])
			);
		}
		System.out.println(dp[n - 1]);
	}
}


Measured memory_bytes: 48416
#include<stdio.h>
int a[10001];
int main(){
  int i;
  a[1]=2;
  for(i=2;i<=10000;i++)a[i]=a[i-1]+i;
  int n;
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",a[n]);
  }
  return 0;   
}

Measured memory_bytes: 632
#include<iostream>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int N; std::cin >> N;
  if(N < 10) fin(N);
  if(N < 100) fin(9);
  if(N < 1000) fin(N-90);
  if(N < 10000) fin(909);
  if(N < 100000) fin(N-9090);
  fin(90909);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int A1[N];
    int A2[N];
    
    for (int i=0; i<N; i++){ cin >> A1[i]; }
    int sum = A1[0];    
    for (int i=0; i<N; i++){ cin >> A2[i];  sum += A2[i]; }
    
    int bef = sum;
    for (int i=1; i<N; i++){
	int tmp = bef - A2[i-1] + A1[i];
	// cout << i << ": " << sum << ", cur: " << tmp << " , bef: " << bef << endl;
	bef = tmp;
	if (tmp > sum){ sum = tmp; }
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define ll long long int
#define M 1000000007
using namespace std;
ll l,r,d[1001][1001];
char ch[1001][1001];
ll max(ll a,ll b)
{
	if(a>b)return a;
	return b;
}
int main()
{
	cin>>l>>r;
	d[1][1]=1; 
	for(int i=1;i<=l;++i)
	{
		for(int j=1;j<=r;++j)
		{
			cin>>ch[i][j];
			if((i+j)!=2){
				if(ch[i][j-1]=='.')d[i][j]+=d[i][j-1];
				if(ch[i-1][j]=='.')d[i][j]+=d[i-1][j];
			}
			d[i][j]%=M;
		}
	}
	if(ch[l][r]=='.')
	{
	cout<<d[l][r];
	}
	else cout<<0;
}

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

using namespace std;

int main()
{
    int n,s=0;
    cin >> n;
    char arr[n+5];
    cin >> arr;

    vector<char>x;
    x.push_back(arr[0]);
    for(int i=1;i<n;i++)
    {
        if(arr[i]!=x[x.size()-1])
        {
            x.push_back(arr[i]);
        }
    }
    cout << x.size();
    return 0;
}


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

using namespace std;
constexpr int INF = 1000000000;

int main() {
  int n,m,w,t;
  cin>>n>>m>>w>>t;
  map<string, pair<int,int>> mp;
  REP(i,m) {
    string s;
    int v,p;
    cin>>s>>v>>p;
    mp[s] = make_pair(v,p);
  }
  vector<tuple<int,int,int>> vt;
  vector<vector<pair<string,int>>> vr(n);
  REP(i,n) {
    int l,x,y;
    cin>>l>>x>>y;
    vt.emplace_back(l,x,y);
    REP(j,l) {
      string r;
      int q;
      cin>>r>>q;
      vr[i].emplace_back(r,mp[r].second-q);
    }
  }
  vector<vector<int>> d(n+1, vector<int>(n+1));
  REP(i,n)REP(j,n) {
    int xi,xj,yi,yj;
    tie(ignore,xi,yi) = vt[i];
    tie(ignore,xj,yj) = vt[j];
    d[i][j] = abs(xi-xj) + abs(yi-yj);
  }
  REP(i,n) {
    int x,y;
    tie(ignore,x,y) = vt[i];
    d[i][n] = d[n][i] = abs(x) + abs(y);
  }
  vector<vector<int>> dist(1<<(n+1), vector<int>((n+1),INF));
  REP(i,n) dist[1<<i][i] = d[n][i];
  REP(i,1<<(n+1)) {
    REP(j,n+1) {
      if ((i>>j)&1) {
        REP(k,n+1) {
          if ((i>>k)&1) continue;
          dist[i|(1<<k)][k] = min(dist[i|(1<<k)][k], dist[i][j] + d[j][k]);
        }
      }
    }
  }
  vector<pair<int,int>> candi;
  REP(i,1<<n) {
    map<string, int> price;
    REP(j,n) {
      if ((i>>j)&1) {
        for (auto p : vr[j]) {
          string r;
          int q;
          tie(r, q) = p;
          if (price.count(r)) {
            price[r] = max(price[r], q);
          } else {
            price[r] = q;
          }
        }
      }
    }
    vector<int> dp(w+1);
    for (auto p : price) {
      string r;
      int q;
      tie(r, q) = p;
      int we = mp[r].first;
      REP(j,w+1-we) {
        dp[j+we] = max(dp[j+we], dp[j] + q);
      }
    }
    candi.emplace_back(dist[i|(1<<n)][n], dp[w]);
  }
  vector<int64_t> dp(t+1);
  for (auto p : candi) {
    int64_t tm, q;
    tie(tm, q) = p;
    REP(i,t+1-tm) {
      dp[i+tm] = max(dp[i+tm], dp[i] + q);
    }
  }
  cout << dp[t] << endl;
  return 0;
}

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


int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  if(a==b){
    for(int i=0; i<a; i++){
      ans += b*pow(10,i);
      }
  }else if(a>b){
    for(int i=0; i<a; i++){
      ans += b*pow(10,i);
    }
  }else{
    for(int i=0; i<b; i++){
      ans += a*pow(10,i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	ll X; cin >> X;

	ll res = X;
	ll low = 0LL;
	ll high = X;

	int iter = 0;
	while(low < high && iter < 30){
		ll mid = (low + high) / 2LL;
		if (mid * (mid + 1LL) / 2LL < X){
			low = mid;
		}else{
			res = min(res, mid);
			high = mid;
		} // end if
		++iter;
	} // end while

	cout << res << endl; 
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int N, K;
	char S[51];
	cin >> N >> K >> S;
	K--;
	if (S[K] == 'A') {
		S[K] = 'a';
	}
	else if (S[K] == 'B') {
		S[K] = 'b';
	}
	else if (S[K] == 'C') {
		S[K] = 'c';
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
 
using namespace std;

ll N;
vector<ll> child[300000];
ll dp[300000];

void dfs(ll cur) {
  ll t = 0;
  for (auto c : child[cur]) {
    dfs(c); 
    t++;
  }
  dp[cur] = t;
}

signed main() {
  cin >> N;
  rep(i, N-1) {
    ll x;
    cin >> x;
    x--;
    child[x].push_back(i+1);
  }
  dfs(0);
  rep(i, N) {
    cout << dp[i] << endl;
  }
  return 0;
}


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

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

    int a,b;
    string s;

    cin >> a >> b >> s;
    
    rep(i,a){
        if(!('0' <= s[i] && s[i] <= '9')){
            cout << "No\n";
            return 0;
        }
    }

    if(s[a] != '-'){
        cout << "No\n";
        return 0;
    }

    rep(i,b - 1){
        if(!('0' <= s[i + a + 1] && s[i + a + 1] <= '9')){
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}

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

//BEGIN CUT HERE
template<typename T>
struct BIT{
  int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(int n_,T d):n(n_),bit(n_+1,d){}

  //bit[i]は長さはiの最後のbit分で、スタートはそれ以外のbit 合計でちょうどiまでの情報
  //最後のbitが表す物をk,それ以外のbitが表す物をlとするとbit[i]=(l,l+k]でl+k=i

  T sum(int i){
    T s=bit[0];
    for(int x=i;x>0;x-=(x&-x))//x&-x:(xの最後のbit) 上の言葉でxをl+kからlにしてる
      s+=bit[x];
    return s;
  }

  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))//k,l+kは自明に増える lは増えない(lとkの間に0が出来ない)
      bit[x]+=a;
  }

  int lower_bound(int w){//w以上となる最小の場所を返す 単調性を仮定してる(bit[i]>=0)
    if(w<=0) return 0;
    int x=0,r=1;
    while(r<n) r<<=1;
    for(int k=r;k>0;k>>=1){//xに2のべき乗を大きい方から足せるなら足すだけ
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;//xはw未満を満たす最大の場所なので1大きい値を返す
  }

  T sum0(int i){
    return sum(i+1);
  }

  void add0(int i,T a){
    add(i+1,a);
  }

  T query(int l,int r){
    return sum(r-1)-sum(l-1);
  }

  T query0(int l,int r){
    return sum(r)-sum(l);
  }
};
//END CUT HERE

signed main(){
  int n,q;cin>>n>>q;
  BIT<long long> bit(n,0);
  for(int i=0;i<n;i++){
    int a;cin>>a;
    bit.add0(i,a);
  }
  while(q--){
    int t,l,r;cin>>t>>l>>r;
    if(t)cout<<bit.query0(l,r)<<endl;
    else bit.add0(l,r);
  }
}


Measured memory_bytes: 8204
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    int i;
    for(i = n; i >= 1; i--){
        int m = sqrt(i);
        if(m*m == i){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func solve(s string, k int) int {
	n := len(s)
	if n == 1 {
		return n * k / 2
	}

	numPer1 := 0
	seqNum := 1
	for i := 1; i < n; i++ {
		if s[i] == s[i-1] {
			seqNum++
		} else {
			numPer1 += seqNum / 2
			seqNum = 1
		}
	}
	lastSeqNum := seqNum

	if s[0] != s[n-1] {
		numPer1 += lastSeqNum / 2
		return numPer1 * k
	}
	if lastSeqNum == n {
		return n * k / 2
	}

	firstSeqNum := 1
	for i := 1; i < n; i++ {
		if s[i] != s[i-1] {
			break
		}
		firstSeqNum++
	}

	ans := numPer1
	numPer1 -= firstSeqNum / 2
	numPer1 += (firstSeqNum + lastSeqNum) / 2
	ans += numPer1 * (k - 1)
	ans += lastSeqNum / 2

	return ans
}

func main() {
	s := input()
	k, _ := strconv.Atoi(input())
	fmt.Println(solve(s, k))
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans=0;
    vector<vector<ll> >arr1(10,vector<ll>(10));
    for(ll i=1;i<=n;i++)
    {
        ll j=i;
        ll temp2=j;
        while(j)
        {
            temp2=j;
            j/=10;
        }
        arr1[temp2][i%10]++;
    }
    for(ll i=1;i<=9;i++)
    {
        for(ll j=1;j<=9;j++)
        {
            ans=ans+arr1[i][j]*arr1[j][i];
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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


int main() {
	ll X;
	cin >> X;

	ll t = gcd(X, 360);

	cout << 360 / t << endl;
}

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

int main(){
    string x,y;
    cin>>x>>y;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(u==x)cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC126
{
	class Program
	{
		static void Main(String[] args)
		{
			// 入力
			int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
			int N = input[0];
			int K = input[1];
			// 計算
			double probability = 0.0;
			int pow = 1;
			int x = N+1;//x~N(Nを含める)までの確率計算をprobabilityに加算した、という情報。最初はNを計算できていないのでN+1で初期化
			while (x > 1)
			{
				// i*pow>=Kとなるようなiを求める(i)
				int i = K / pow;
				if (K%pow!=0){
					// 割り切れない場合は、K=i*pow+alpha(pow>alpha>0)よりi*pow<K && (i+1)*pow>=Kなので、iを1増やす
					i++;
				}
				// iがxより小さくなったら、何個の確率計算がこのループでできるかを調べる
				int count = x - i;
				if (count>0)
				{
					// xを更新
					x = i;
					// probabilityに、調べた個数分の確率を追加する（1つ当たり 1/N/pow である）
					double add = 1.0 * count / N / pow;
					probability += add;
				}
				// powの更新
				pow *= 2;
				// x<=1なら、計算終了
			}
			// 出力
			Console.WriteLine(probability);
		}
	}
}

Measured memory_bytes: 11092
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
from heapq import heappush, heappop
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


# nより小さい素数のリストを生成
def make_prime_list(n: int):
    num = [True] * n
    num[0] = num[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if num[i]:
            for j in range(i ** 2, n, i):
                num[j] = False

    return num


class CumulativeSum:
    def __init__(self, l):
        self.dp = [0] * (len(l) + 1)
        for i, v in enumerate(l):
            self.dp[i + 1] = v + self.dp[i]

    # return sum(l[left] + l[left + 1] + ... + l[right])
    def total(self, left, right):
        assert 0 <= left <= right < len(self.dp)
        return self.dp[right + 1] - self.dp[left]


def main():
    Q = int(input())

    prime_list = make_prime_list(10 ** 5 + 5)
    memo = [0] * (10 ** 5 + 5)
    for i in range(10 ** 5 + 1):
        memo[i] = prime_list[i] and prime_list[(i + 1) // 2]

    c = CumulativeSum(memo)
    for _ in range(Q):
        l, r = map(int, input().split())
        print(c.total(l, r))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include<algorithm>
#include<iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,(n))
#define MAX_N 105

int N,M,P;
int x[MAX_N];

bool input(){
  REP(i,MAX_N)x[i]=0;
  cin>>N>>M>>P;

  REP(i,N)cin>>x[i];

  return (N!=0);
}

void solve(){
  int total=0;
  REP(i,N)total+=x[i];
  total*=(100-P);
  if(x[M-1]==0)cout<<0<<endl;
  else {
    int ans=total/x[M-1];
  cout<<ans<<endl;
  }
}
int main(){
  while(input())solve();
  return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>

using namespace std;

int main(){
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K){
    cout << S << "\n";
  }
  else{
    cout << S.substr(0, K) << "..." << "\n";
  }
  return 0;
}

Measured memory_bytes: 3628
import qualified Data.ByteString.Char8 as B
import           Data.Maybe (fromJust)

main :: IO ()
main = do
  [a, b, h, m] <- getInts
  let alpha = (fromIntegral h + beta) / 12
      beta = fromIntegral m / 60
      theta = 2 * pi * (alpha - beta)
      ans = lawOfCos (fromIntegral a) (fromIntegral b) theta
  print ans

getInts :: IO [Int]
getInts = fmap (fst . fromJust . B.readInt) . B.words <$> B.getLine

lawOfCos :: Double -> Double -> Double -> Double
lawOfCos b c alpha = sqrt a2
  where
    a2 = b ^ (2 :: Int) + c ^ (2 :: Int) - 2 * b * c * cos alpha


Measured memory_bytes: 4212
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define RG register
#define il inline
#define iter iterator
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long ll;
void work()
{
	ll N;cin>>N;
	ll t1,t2;
	for(ll h=1;h<=3500;h++){
		for(ll w=1;w<=3500;w++){
			t1=N*h*w;
			t2=4*h*w-h*N-N*w;
			if((t1*t2)>0 && t1%t2==0){
				printf("%lld %lld %lld\n",h,w,t1/t2);
				return ;
			}
		}
	}
}

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


Measured memory_bytes: 256
#include <stdio.h>

main()
{

	int a, b;

	scanf("%d %d", &a, &b);

	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else if(a==b)
	{
		printf("a == b\n");
	}

	return 0;

}

Measured memory_bytes: 580
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int a[N],b[N],c[M],d[M];
  REP(i,N)cin>>a[i]>>b[i];
  REP(i,M)cin>>c[i]>>d[i];
  REP(i,N){
    int min=abs(a[i]-c[0])+abs(b[i]-d[0]);
    int ans=0;
    FOR(j,1,M){
      if((int)(abs(a[i]-c[j])+abs(b[i]-d[j]))<min){
        min=abs(a[i]-c[j])+abs(b[i]-d[j]);
        ans=j;
      }
    }
    cout<<ans+1<<endl;

  }
  return 0;
}


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

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1000000007;

ll N;

ll f(ll v, ll k){
    if(v < k) return 0;
    return v / k / 2 + f(v / k, k);
}

int main(){
    ios_base::sync_with_stdio(false);
	cin >> N;
    if(N & 1LL){
        cout << 0 << endl;
        return 0;
    }
    cout << f(N, 5) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC119_A
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string input = Console.ReadLine();
			int year = int.Parse(input.Substring(0, 4));
			int month = int.Parse(input.Substring(5, 2));
			int day = int.Parse(input.Substring(8, 2));

			if (year < 2019)
			{
				Console.WriteLine("Heisei");
				return;
			}

			if (year == 2019)
			{
				if (month < 4)
				{
					Console.WriteLine("Heisei");
					return;
				}else if (month == 4 && day <= 30)
				{
					Console.WriteLine("Heisei");
					return;
				}
			}
			
			Console.WriteLine("TBD");
		}
	}
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll N, M;
    cin >> N >> M;
    vector<ll>v(N);
    rep(i, N)cin >> v[i];
    sort(v.begin(), v.end());
    ll cnt = 0, len = 1, num = 1;
    queue<ll>Q;
    Q.push(v[0]);
    for(ll i = 1; i < N; i++){
        while(!Q.empty() && Q.front() < v[i] - M){
            cnt++;
            Q.pop();
        }
        num = num * (len + 1 - cnt) % MOD;
        // cout << i << " : " << num << " " << cnt << endl;
        len++;
        Q.push(v[i]);
    }
    cout << num << endl;

    return 0;
}


Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
int n,ok,a[200004];
vector<int>v;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n;
v.push_back(0);
for(int i=1;i<n+1;i++){
	 cin>>a[i];
	 if(a[i]==v.size()){
	 	 v.push_back(a[i]);
	 }
	 else{
	 	 ok++;
	 }
}
if(ok==n){
	 cout<<-1;
}
else{
     cout<<ok;
}
return 0;
}


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

int dp[100005];

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

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

const int N = int(2e5)+10;
const int K = int(2e6)+10;
const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 2e18;

ll a[N],b[N],pre[N];

void solve () {
    int n,m;cin>>n>>m;
    ll k;cin>>k;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=m;i++) {
        cin>>b[i];
        pre[i] = pre[i-1] + b[i];
    }
    ll curr = 0;
    int j = m;
    while (j >= 0 && pre[j] > k) j--;
    int ans = j;
    for (int i=1;i<=n;i++) {
        curr += a[i];
        if (curr > k) break;
        while (j >= 0 && pre[j] > k - curr) j--;
        ans = max(ans,i+j);
    }
    cout<<ans<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

using namespace std;

int main()
{
    long long r, d, x;
    cin >> r >> d >> x;

    for (int i=2001; i<=2010; ++i)
    {
	x = (r*x) - d;
	cout << x << '\n';
    }

    return 0;
}


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

int main(){
  int n;
  while(cin >> n,n != 0){
    int ppl[10] = {};
    int ba = 0;
    string s;
    cin >> s;

    int p = 0;
    for(int i = 0;i < 100;i++){
      ppl[p]++;
      switch(s[i]){
        case 'S':
          ba += ppl[p];
          ppl[p] = 0;
          break;
        case 'L':
          ppl[p] += ba;
          ba = 0;
          break;
      }
      p = (p+1) % n;
    }

    sort(ppl,ppl+n);

    for(int i = 0;i < n;i++) cout << ppl[i] <<  " " ;
    cout << ba << endl;
  }
  return 0;

}





Measured memory_bytes: 3152
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

cnt1, cnt2, cnt3 = 0, 0, 0
for i in range(N):
    if P[i] <= A:
        cnt1 += 1
    elif A < P[i] <= B:
        cnt2 += 1
    else:
        cnt3 += 1
print(min(cnt1, cnt2, cnt3))


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 1009
void run(void) {
	char s[N], t[N];
	int ans = 0;
	in("%s%s", s, t);
	int ls = strlen(s), lt = strlen(t);
	rep(i, ls - lt + 1) {
		int d = 0;
		rep(j, lt)if (t[j] == s[j + i])d++;
		ans = Ma(ans, d);
	}
	printf("%d\n", lt - ans);
}

int main(void) {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
	}
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

int prime[100000];
bool is_prime[1000000];

int sosuu(int n){
    int p=0;
    for (int i=0; i<=n; i++)
        is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for (int i=2; i<=n; i++) {
        if(is_prime[i]){
            prime[p++]=i;
            for (int j=i*2; j<=n; j+=i) {
                is_prime[j]=false;
            }
        }
    }
    return p;
}

int main(void){
    int n;
    while(cin>>n)
    cout<<sosuu(n)<<endl;
    return 0;
}

Measured memory_bytes: 2444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
 struct edge{lint too,cost;};
 lint ans[100000];
 vector<vector<edge>> g;
 void dfs(lint to,lint from=-1,lint color=0){
     ans[to]=color;
    rep(i,g[to].size()){
         if(g[to][i].too==from)continue;
         lint a=g[to][i].cost;
         lint color1;
         if(a%2==1&&color==0)color1=1;
          if(a%2==1&&color==1)color1=0;
           if(a%2==0&&color==0)color1=0;
            if(a%2==0&&color==1)color1=1;
            dfs(g[to][i].too,to,color1);
     
 }
 }
  int main(){
        lint N;
        cin>>N;
        g.resize(N);
        rep(i,N-1){
            lint u,v,w;
            cin>>u>>v>>w;
            u--;v--;
            g[u].push_back({v,w});
            g[v].push_back({u,w});
        }
        dfs(0);
        rep(i,N){
            cout<<ans[i]<<endl;
        }
  }
  

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int x, y;

bool check(vector<int>& dir, int goal, int start) {
  unordered_set<int> last;

  last.insert(start);

  for (auto& e : dir) {
    unordered_set<int> cur;

    for (auto& d : last) {
      cur.insert(d + e);
      cur.insert(d - e);
    }

    last = cur;
  }

  return last.find(goal) != last.end();
}

int main(void) {
  // Here your code !
  cin >> s;

  if (s.back() == 'F') s.push_back('T');

  scanf("%d %d", &x, &y);

  vector<int> dir_x;
  vector<int> dir_y;

  int parity = 0;
  int cur = 0;

  for (auto& e : s) {
    if (e == 'T') {
      if (parity % 2 == 0) {  // direction: x
        dir_x.push_back(cur);
      } else {  // direction: y
        dir_y.push_back(cur);
      }
      cur = 0;
      parity += 1;
    } else {
      cur += 1;
    }
  }

  int beg_x = 0;
  int beg_y = 0;

  if (s[0] == 'F') {
    beg_x += dir_x[0];
    dir_x.erase(dir_x.begin());
  }

  if (check(dir_x, x, beg_x) && check(dir_y, y, beg_y)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 768
a=[]
b=[]
n,m=map(int,input().split())
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    c=0
    for j in range(m):
        c+=a[i][j]*b[j]
    print(c)


Measured memory_bytes: 6008
N = int(input())
A = [int(x) for x in input().split()]

m1 = sum(A) // N
cost1 = 0
for i in range(N):
    cost1 += (A[i] - m1)** 2

m2 = m1 + 1
cost2 = 0
for i in range(N):
    cost2 += (A[i] - m2) ** 2

print(min(cost1, cost2))


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

const int max_e = 100, dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
char field[max_e][max_e];
int w, h, data[max_e][max_e];
void dfs(int y, int x, int res){
	for(int i = 0; i < 4; i++){
		if(x+dx[i] >= 0 && y+dy[i] >= 0 && x+dx[i] < w && y+dy[i] < h
		 && field[y][x] == field[y+dy[i]][x+dx[i]] && data[y+dy[i]][x+dx[i]] == 0){
		 	data[y+dy[i]][x+dx[i]] = res;
			dfs(y+dy[i], x+dx[i], res);
		}
	}
	return;
}
int main(){
	while(true){
		int res = 0;
		scanf("%d%d", &h, &w);
		if(h == 0 && w == 0) return 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				data[i][j] = 0;
			}
		}
		for(int i = 0; i < h; i++){
			scanf("%s", field[i]);
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(data[i][j] == 0){
					data[i][j] = ++res;
					dfs(i, j, res);
				}
			}
		}
		printf("%d\n", res);
	}
}

Measured memory_bytes: 1704
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    pair<double,double>   pd;
typedef    vector<pd>   vpd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{
ll n,m;
cin>>n>>m;
ll a[m];
ll s=0;
for(int i=0;i<m;i++)
{cin>>a[i];
s+=a[i];
}

n-=s;
if(n>=0)
cout<<n;
else
cout<<-1;











}return 0;}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include<stdlib.h>
#include <dirent.h>
using namespace std;
#define sp << " " << 
typedef vector<int> vi;
typedef vector<long int> vli;
typedef vector<long long int> vlli;
typedef long int li;
typedef long long int lli;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<lli,lli> > vplli;
typedef unordered_map<int,int> ump;

int main(){
    int n;
    cin >> n;
    vector<int> arr;
    for(int i=0;i<n;i++){
        int input;
        cin >> input;
        arr.push_back(input);
    }
    if(n==1){
        return 0;
    }
    int var1=0;
    int var2=abs(arr[1]-arr[0]);

    for(int i=2;i<n;i++){
        int aux = min(abs(arr[i]-arr[i-2])+var1, abs(arr[i]-arr[i-1])+var2);
        
        var1=var2;
        var2=aux;
    }
    cout << var2 << endl;


    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    bool bad = false;
    for (int i=0; i <= 2; i++)
    {
        if (S[i] == S[i+1])
            bad = true;
    }

    if (bad)
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;
    
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    int n=sc.nextInt();
    int t=sc.nextInt();
    int[] a = new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    long sum=0;
    int end=0;
    for(int i=0;i<n;i++){
      sum+=Math.min(a[i]+t-end,t);
      end=a[i]+t;
    }
    System.out.println(sum);
  }
}

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

// dependency
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    long long g = gcd(a, b);
    return a / g * b;
}

/*
    verified https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_1_B
*/
int main() {
    long long a, b;
    while (cin >> a >> b) {
        long long g = gcd(a, b);
        long long l = lcm(a, b);
        cout << g << " " << l << endl;
    }
}



Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ba(M);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        ba[i] = make_pair(b-1, a);
    }

    ba.push_back(make_pair(-100, -100));

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

    int pos = ba[0].first;
    int ans = 0;
    for(int i=1; i<M+1; i++){
        if(ba[i].second <= pos) continue;
        pos = ba[i].first;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  int a=1;
  vector<double> x(N);
  vector<double> y(N);
for (int i=0;i<N;i++) {
  cin>>x.at(i);
  cin>>y.at(i);
  a*=i+1;
}
  double Z=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      Z+=sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
    }
  }
  cout << fixed << setprecision(10);

  cout<<Z*2/N<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// grand-garden.rs --- Grand Garden
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        hs: [u32; n],
    };

    let mut ans = 0;
    for i in 1..101 {
        ans += hs
            .split(|&h| h < i)
            .filter(|&part| !part.is_empty())
            .count();
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const double pie = 3.14159265358979;

int main(){
    double a, b, x, ans;
    cin >> a >> b >> x;
    if (2*x > a*a*b) {
        ans = atan(2 * (b/a - x/(a*a*a)));
    }
    else{
        ans = atan(0.5 * a * b * b / x);
    }
    cout << fixed << setprecision(10) << ans / pie * 180 << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))

e = [0 for i in range(n)]

if d[0] != 0:
    print(0)
    exit()

for i in d:
    e[i] += 1

# print(e)

ans = 1

for i in range(1, n):
    ans *= e[d[i] - 1]
    ans %= 998244353
print(ans)


Measured memory_bytes: 20760
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
# メモ化関数定義
def memoize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func
@memoize
def rec(v):
    res=0
    for nv in graph[v]:
        res=max(res,rec(nv)+1)
    return res
def main():
    n,m=map(int,input().split())
    XY=[tuple(map(int,input().split())) for i in range(m)]
    global graph
    graph=[[]for _ in range(n)]
    for x,y in XY:
        graph[x-1].append(y-1)
    ans=0
    for v in range(n):
        ans=max(ans,rec(v))
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 144808
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
N, M = map(int,input().split())
UFT = UnionFind(N)
 
for _ in range(M):
    A, B = map(int,input().split())
    UFT.union(A-1, B-1)
 
ans = 0
for i in range(N):
    ans = max(ans, UFT.size(i))
print(ans)

Measured memory_bytes: 14484
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String  A = sc.next();
    char[] a = A.toCharArray();
    ArrayList<Character> aa = new ArrayList<>();

	for(int i=0; i<4; i++){
	if(!aa.contains(a[i])){
		aa.add(a[i]);
	}
}
	if(aa.size() == 2){
		System.out.println("Yes");
	}else{
		System.out.println("No");
	}
	}
}


Measured memory_bytes: 20820