akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

void Main()
{
  i64 k,n;
  cin >> k >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  i64 m = a[0] + (k-a[n-1]);
  rep(i,n-1)
    chmax(m,a[i+1]-a[i]);
  
  cout << k - m << endl;
}

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



Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
#include <math.h>
//#include <vector>

using namespace std;


long int gcd(long int a, long int b){
  long int r;

  if(a < b) gcd(b, a);  
  while ((r=a%b)) {    
    a = b;
    b = r;
  }
  return b;  
}



int main() {
  int N, K;
  //  long int A[100000];
  long int tmp;
  long int max;
  long int gc;

  int i;
  
  cin >> N >> K;

  
  cin >> gc;
  max = gc;
  for(i=1;i<N;i++){
    cin >> tmp;
    if(tmp > max) max = tmp;
    gc = gcd(gc,tmp);
  }

  if(K>max) cout << "IMPOSSIBLE";
  else if(K%gc==0){
    cout << "POSSIBLE";
  }else{
    cout << "IMPOSSIBLE";
  }
 
  return 0;
}


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

int main(){
	int a, b;
	for(int i=0; i>=0; i++){
		cin >> a >> b;
		if(a==0 && b==0) break;
		for(int j=0; j<a; j++){
			for(int k=0; k<b; k++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define maxn 2500000
#define mod 1000000007
#define maxm 4020
#define int long long
int n, a[maxn], b[maxn], inv[maxn], fac[maxn];
int ans, m, S = 2005, f[maxm][maxm];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

void Up(int &x, int y) { x = (x + y) % mod; }
int C(int n, int m)
{
	if(n < m || m < 0 || n < 0) return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

void pre()
{
	fac[0] = fac[1] = 1; inv[0] = inv[1] = 1; 
	for(int i = 2; i < maxn; i ++) fac[i] = fac[i - 1] * i % mod; 
	for(int i = 2; i < maxn; i ++) inv[i] = (mod - mod / i) * inv[mod % i] % mod; 
	for(int i = 2; i < maxn; i ++) inv[i] = inv[i] * inv[i - 1] % mod;
}

signed main()
{
	pre(); n = read();
	for(int i = 1; i <= n; i ++)
	{
		a[i] = read(), b[i] = read();
		f[-a[i] + S][-b[i] + S] ++;
	}
	m = 2 * S;
	for(int i = 1; i <= m; i ++)
		for(int j = 1; j <= m; j ++)
			Up(f[i][j], (f[i - 1][j] + f[i][j - 1]) % mod); 
	for(int i = 1; i <= n; i ++) 
	{
		Up(ans, f[a[i] + S][b[i] + S]);
		Up(ans, mod - C(2 * (a[i] + b[i]), 2 * a[i]));
	}
	printf("%lld\n", ans * inv[2] % mod);
	return 0;
}

Measured memory_bytes: 172288
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <map>
#define llint long long

using namespace std;

struct vec2d{
	llint x, y;
	vec2d(){}
	vec2d(llint x, llint y){
		this->x = x, this->y = y;
	}
	llint add(llint a, llint b){
		return a+b;
	}
	vec2d operator+(vec2d ope){
		return vec2d(add(x, ope.x), add(y, ope.y));
	}
	vec2d operator-(vec2d ope){
		return vec2d(add(x, -ope.x), add(y, -ope.y));
	}
	vec2d operator*(llint t){
		return vec2d(x*t, y*t);
	}
	vec2d operator/(llint t){
		return vec2d(x/t, y/t);
	}
	llint dot(vec2d ope){
		return add(x*ope.x, y*ope.y);
	}
	llint cross(vec2d ope){
		return add(x*ope.y, -y*ope.x);
	}
};

llint n;
vector<vec2d> vec, vecx, vecy, vecxy;
llint area[100005], areay[100005], areax[100005], areaxy[100005];


bool compare(vec2d u, vec2d v)
{
	if(u.x < v.x) return true;
	if(u.x > v.x) return false;
	return u.y < v.y;
}

void calc(vector<vec2d> &vec, llint area[], llint sgn)
{
	vector<vec2d> poly;
	poly.resize(vec.size());
	
	llint k = -1, s = 0;
	for(int i = 0; i < vec.size(); i++){
		while(k >= 1 && sgn*(vec[i]-poly[k]).cross(poly[k]-poly[k-1]) >= 0 ){
			s -= abs((poly[k]-poly[0]).cross(poly[k-1]-poly[0]));
			k--;
		}
		poly[k+1] = vec[i];
		s += abs((poly[k]-poly[0]).cross(poly[k+1]-poly[0]));
		k++;
		area[i] = s;
	}
}

int main(void)
{
	cin >> n;
	llint x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		vec.push_back(vec2d(x, y));
		vecy.push_back(vec2d(x, y));
		vecx.push_back(vec2d(-x, y));
		vecxy.push_back(vec2d(-x, y));
	}
	
	if(n <= 2){
		cout << 0 << endl;
		return 0;
	}
	
	sort(vec.begin(), vec.end(), compare);
	sort(vecy.begin(), vecy.end(), compare);
	sort(vecx.begin(), vecx.end(), compare);
	sort(vecxy.begin(), vecxy.end(), compare);
	
	calc(vec, area, 1);
	calc(vecy, areay, -1);
	calc(vecx, areax, 1);
	calc(vecxy, areaxy, -1);
	
	map<llint, llint> mp, mpx;
	for(int i = 0; i <= n-1; i++){
		if(i == n-1 || vec[i].x != vec[i+1].x){
			mp[vec[i].x] += area[i];
			mp[vecy[i].x] += areay[i];
		}
	}
	for(int i = 0; i <= n-1; i++){
		if(i == n-1 || vecx[i].x != vecx[i+1].x){
			mpx[-vecx[i].x] += areax[i];
			mpx[-vecxy[i].x] += areaxy[i];
		}
	}
	
	llint ans = mpx[mp.begin()->first];
	for(auto it = mp.begin(); it != mp.end(); it++){
		llint tmp = it->second;
		auto it2 = it; it2++;
		if(it2 != mp.end()) tmp += mpx[it2->first];
		ans = min(ans, tmp);
	}
	cout << (ans+1)/2 << endl;
	return 0;
}


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

int main() {
  std::vector<size_t> a(3);

  for (size_t i=0; i<3; i++)
    std::cin >> a[i];

  std::sort(a.begin(), a.end());

  auto ans = a[2] * 10 + a[1] + a[0];

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
template<typename T>
class stack
{
  T elements[10000];
  int index=-1;
public:
  void push(T num)
  {
    index++;
    elements[index]=num;
  }
  void pop()
  {
    index--;
  }
  T peep()
  {
    if(index==-1)return 0;
    else
    return elements[index];
  }
  bool empty()
  {
    if(index==-1)
      return true;
    else
      return false;
  }
};
template<typename T>
class queue
{
  T elements[1000];
  int fronte=-1;
  int rear=-1;
public:
  void enqueue(int num)
  {
    if(rear==-1)
    {
      rear++;
      fronte++;
    }
    else
    {
      rear++;
    }
    elements[rear]=num;
  }

void dequeue()
{
  fronte++;
  if(fronte>rear)
  {
    fronte=-1;
    rear=-1;
  }
}
T front()
{
  return elements[fronte];
}
T back()
{
  return elements[rear];
}
bool empty()
{
  if(fronte==-1 && rear==-1)
    return true;
  else 
    return false;
}
void print()
{
  for(int i=fronte;i<=rear;i++)
    cout << elements[i] << " ";
  cout << endl;
}
};
typedef long long ll;
#define mod 1000000007
ll modulo(ll base,ll power)
{
  ll res=1;
  while(power>0)
  {
    if(power%2)
      res=(res*1ll*base)%mod;
    base=(base*1ll*base)%mod;
    power/=2;
  }
  return res;
}
int main() {
 int n;
 cin >> n;
 int ans=(modulo(10,n)%mod+modulo(8,n)%mod)%mod;
 ans=ans-(2*modulo(9,n)%mod)%mod;
 ans+=mod;
 ans=ans%mod;
 cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
import operator
import bisect

n=int(input())
red=[tuple(map(int,input().split())) for _ in range(n)]
blue=[tuple(map(int,input().split())) for _ in range(n)]

red.sort(key=operator.itemgetter(0,1))
blue.sort(key=operator.itemgetter(0,1))
#print(red)
#print(blue)
count=0
for i in range(n):
  for j in reversed(range(len(red))):
    #print("j",j)
    if not red:
      break
    if red[j][0]<blue[i][0]:
      tmp=red[:j+1]
      tmp.sort(key=lambda x:x[1],reverse=True)
      for t in tmp:
        if t[1]<blue[i][1]:
          count+=1
          red.pop(red.index(t))
          #print("t",t,"blue[i]",blue[i])
          break
    else:
      continue
    break

print(count)
    

Measured memory_bytes: 9228
require "set"

def max(a, b); a < b ? b : a; end
def min(a, b); a < b ? a : b; end

class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @k = gets.to_s.to_i
    @cnt = Set.new
  end

  def solve
    i = 1
    n = 7
    loop do
      return i if n % k == 0
      n = n * 10 + 7
      n %= k
      i += 1
      return -1 if @cnt.include?(n)
      @cnt << n
    end
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


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

const ll mod = 1000000007;

int main(){
	int n, m; cin >> n >> m;
	vector<ll> H(n);
	rep(i,n){
		cin >> H.at(i);
	}
	vector<vector<int>> G(n);
	rep(i, m){
		int a, b; cin >> a >> b; 
		a--; b--;
		G.at(a).push_back(b);
		G.at(b).push_back(a);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		bool ok = true;
		for(int j = 0; j < G.at(i).size(); j++){
			
			if(H.at(G.at(i).at(j)) >= H.at(i)) ok = false;
		}
		if(ok){ 
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9068
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ORDER 500000

struct NODE{
  int key,nil;
  struct NODE *left,*right,*parent;
};

typedef struct NODE Node;

Node *head;

void insert(Node*);
void print1(Node*);
void print2(Node*);
int find(Node*,int);

int main(){
  int i,num;
  Node *n;
  char order[ORDER][10];
  Node tmp;
  
  scanf("%d",&num);

  n = (Node *)malloc(sizeof(Node) * num);

  for(i=0; i<num; i++){
    scanf("%s",order[i]);
    if(strcmp(order[i],"print")!=0)scanf("%d",&n[i].key);
  }  
  
  for(i=0; i<num; i++){
    if(strcmp(order[i],"insert")==0) insert(&n[i]);
    if(strcmp(order[i],"print")==0){
      print1(head);
      printf("\n");
      print2(head);
      printf("\n");
    }
    if(strcmp(order[i],"find")==0){
      if(find(head,n[i].key)==1) printf("yes\n");
      else printf("no\n");
    }
  }
  
  return 0;
}



void insert(Node *z){
  Node *y,*x;
  
  z->left = NULL;
  z->right = NULL;
  y = NULL;
  x = head;

  while(x != NULL){
    y = x;
    if(z->key < x->key)  x = x->left;
    else x = x->right;    
  }

  z->parent = y;
  
  if(y == NULL) head = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}


void print1(Node *node){
  if(node == NULL){
    return;
  }
  
  print1(node->left);
  printf(" %d",node->key);
  print1(node->right);
  return ;
}


void print2(Node *node){
  if(node == NULL){
    return;
  }
  
  printf(" %d",node->key);
  print2(node->left);
  print2(node->right);
  return;
}

int find(Node* node,int num){
  int found=0;
  if(node == NULL){
    return 0;
  }
  
  if(node->key == num) found=1;
  if(node->key > num) found = find(node->left,num);
  if(node->key < num) found = find(node->right,num);
  
  return found;
}

Measured memory_bytes: 21128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
	//最大値が更新されるとき、高さは一意に決まり、それ以外は今まで登ってきた山の中から最も高い山の標高通りある。
	//更新されるときときに相手が自分より低いと矛盾になる(相手は自分より先を見てきたはずなので)
	int n;
	cin>>n;
	vector<ll>t(n),a(n);
	ll maxv=0,maxv2=0;
	vector<ll>cnt(n),cnt2(n);
	rep(i,n)cin>>t[i];
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(!chmax(maxv,t[i]))cnt[i]=t[i];
		else {
			if(maxv>a[i])cnt[i]=0;
			else cnt[i]=1;
		}
	}
	for(int i=n-1;i>=0;--i){
		if(!chmax(maxv2,a[i]))cnt2[i]=a[i];
		else {
			if(maxv2>t[i])cnt2[i]=0;
			else cnt2[i]=1;
		}
	}
	ll ans=1;
	rep(i,n){
		ans*=min(cnt[i],cnt2[i]);
		ans%=mod;
	}
	cout<<ans<<"\n";
}

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


Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const int INF = 1001001001;
const double pi = acos(-1);

vector<pair<ll, ll>> prime_factorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> a = prime_factorize(n);
    cout << n << ":";
    for (int i = 0; i < a.size(); i++)
    {
        int x = a[i].fi;
        int y = a[i].se;
        for (int j = 0; j < y; j++)
        {
            cout << " " << x;
        }
    }
    cout << endl;

    return 0;
}



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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N;
  cin >> N;
  cout << ((N & 1) == 1 ? N * 2 : N) << endl;
}

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

using namespace std;

int main()
{
    int i,count=0;
    char S[3],T[3];
    for(i=0;i<3;i++)
    {
        cin>>S[i];
    }
    for(i=0;i<3;i++)
    {
        cin>>T[i];
    }
    for(i=0;i<3;i++)
    {
        if(S[i]==T[i])
        {
            count++;
        }
    }
    cout<<count;

    return 0;
}

Measured memory_bytes: 256
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-7-7 21:58:13
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

typedef tuple<ll, int> P;

int N, M;
int S[2];
vector<P> V[2][100010];
priority_queue<P, vector<P>, greater<P>> Q[2];
ll dist[2][100010];
ll ans[100010];

int main()
{
  cin >> N >> M >> S[0] >> S[1];
  S[0]--;
  S[1]--;
  for (auto i = 0; i < M; i++)
  {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    V[0][u].push_back(P(a, v));
    V[0][v].push_back(P(a, u));
    V[1][v].push_back(P(b, u));
    V[1][u].push_back(P(b, v));
  }
  fill(&dist[0][0], &dist[0][0] + 2 * 100010, -1);
  for (auto k = 0; k < 2; k++)
  {
    Q[k].push(P(0, S[k]));
    while (!Q[k].empty())
    {
      ll d = get<0>(Q[k].top());
      int now = get<1>(Q[k].top());
      Q[k].pop();
      if (dist[k][now] == -1)
      {
        dist[k][now] = d;
        for (auto x : V[k][now])
        {
          ll new_d = get<0>(x);
          int dst = get<1>(x);
          if (dist[k][dst] == -1)
          {
            Q[k].push(P(d + new_d, dst));
          }
        }
      }
    }
  }
  for (auto i = 0; i < N; i++)
  {
    ans[i] = dist[0][i] + dist[1][i];
    //cerr << "dist[0][" << i << "] = " << dist[0][i] << endl;
    //cerr << "dist[1][" << i << "] = " << dist[1][i] << endl;
  }
  for (auto i = N - 1; i >= 1; i--)
  {
    ans[i - 1] = min(ans[i - 1], ans[i]);
  }
  ll X = 1000000000000000;
  for (auto i = 0; i < N; i++)
  {
    cout << X - ans[i] << endl;
  }
}

Measured memory_bytes: 21368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
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 sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(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 MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//ワーシャルフロイド
//頂点数（と隣接行列）を引いて全点間最短距離を返す
//O(V^3)
ll cost[310][310];
ll dddd[310][310];

void waasharuhuroido(ll n){
	rep(i,0,n)rep(j,0,n)dddd[i][j]=cost[i][j];//辺が無いところはINFにする前処理が必要
	rep(k,0,n)rep(i,0,n)rep(j,0,n)dddd[i][j]=min(dddd[i][j],dddd[i][k]+dddd[k][j]);
}

int main(){
	ll n,m,L;
	scanf("%lld%lld%lld",&n,&m,&L);
	rep(i,0,n)rep(j,0,n)cost[i][j]=INF;
	rep(i,0,m){
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		x--,y--;
		cost[x][y]=cost[y][x]=z;
	}
	waasharuhuroido(n);
	rep(i,0,n)rep(j,0,n)cost[i][j]=dddd[i][j]<=L?1:INF;
	waasharuhuroido(n);
	
	ll q;
	scanf("%lld",&q);
	while(q--){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		ll ans=dddd[x][y];
		printf("%lld\n",ans==INF?-1:ans-1);
	}
}

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

table = []
for _ in range(n):
    table += [list(map(int, input().split()))]

ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            x = 0
            for k in range(d):
                x += (table[i][k] - table[j][k]) ** 2
            if x ** 0.5 % 1 == 0:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int gcd(int x,int y){
    if(x==0)return y;
    return gcd(y%x,x);
}
int main(void){
	int i,a,b,c;
	while(scanf("%d%d",&a,&b)!=EOF){
	    c=gcd(a,b);
	    printf("%d %d\n",c,a/c*b);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}

int main(){
        ll n;
        cin>>n;
        ll answer=0;
        vll a(n+1,0);
        rep(i,1,n+1,1){
            cin>>a[i];
            if(a[i]%2==1 && i%2==1)answer++;
        }
        cout<<answer<<endl;
}



Measured memory_bytes: 81212
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n;
  cin >> n;
  int ans = 1;
  LOOP1(i,n){
    ans*=i;
    ans%=1000000007;
  }
  cout << ans << endl;;
}


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


int main() {
	vector<vector<int>> c(3, vector<int>(3));
	rep(i, 0, 3) rep(j, 0, 3) cin >> c[i][j];

	rep(i, 0, 2) {
		rep(j, 0, 2) {
			if (c[i][j] + c[i + 1][j + 1] == c[i + 1][j] + c[i][j + 1]) continue;
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

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

int main() {
	double n, d, x, ans;
	scanf("%lf%lf%lf", &n, &d, &x);
	for (d += (n - 0.5) * x; n; n--) {
		ans += d;
		d += d / n;
	}
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 256
/*
「God Is In His Heaven,
		All's Right With The World.」
*/
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(a)-1; i>=(b); i--)
#define each(i, q) for(auto i : q)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define lowbit(x) x&(-x)
#define all(x) x.begin(),x.end()
#define ffs __builtin_ffs //idxOf(1<-) 
#define clz __builtin_clz //numOf(->0) 
#define ctz __builtin_ctz //numOf(0<-)
#define popcount __builtin_popcount //numOf1
#define parity __builtin_parity //(numOf1)%2
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
template <typename T> inline void read(T& x) {
	int f = 0, c = getchar(); x = 0;
	while (!isdigit(c)) f |= c == '-', c = getchar();
	while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
	if (f) x = -x;
}
template <typename T, typename... Args>
inline void read(T& x, Args& ... args) {
	read(x); read(args...);
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + 48);
}
template <typename T> void writes(T x) { write(x); putchar(' '); }
template <typename T> void writeln(T x) { write(x); puts(""); }
template <typename T> inline bool chkmin(T& x, const T& y) { return y < x ? (x = y, true) : false; }
template <typename T> inline bool chkmax(T& x, const T& y) { return x < y ? (x = y, true) : false; }
const int maxn = (int)3e5 + 10;
const ll inf = (ll)1e18;
const int mod = (int)1e9 + 7;
/*
	——ASUKA STRIKES!
*/
int main() {
	ll a, b, k;
	read(a, b);
	k = 2 * a - 2 * b;
	ll t = a * a - b * b;
	if (t % k) puts("IMPOSSIBLE");
	else {
		t /= k;
		cout << t << endl;
	}
}

Measured memory_bytes: 256
def bubble_sort(n, as)
  count = 0
  i = 0
  while i < n do
    j = n - 1
    while j > i do
      target = as[j]
      if target < as[j - 1]
        as[j] = as[j - 1]
        as[j - 1] = target
        count = count + 1
      end
      j = j - 1
    end
    i = i + 1
  end
  puts as.join(' ')
  puts count
end

n = STDIN.gets.to_i
as = STDIN.gets.split(' ').map {|x| x.to_i }
bubble_sort(n, as)



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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

char d;
int a,b;
int main()
{
 
    cin>>a>>d>>b;
    if(d=='+')
        cout<<a+b;
    else
        cout<<a-b;
}




Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int a=0;

	if(s[0]==t[0]){a++;}
	 if(s[1]==t[1]){a++;}
	 if(s[2]==t[2]){a++;}
	
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1e9+7;

signed main() {
  string S;
  cin >> S;
  
  //前からi文字の時点で、13で割った余りがjであるものの個数
  vector<vector<int>> dp((int)S.size(), vector<int>(13));
  if( S.at(0) == '?' ){
    for( int j = 0; j < 10; j++ ) dp[0][j] = 1;
  }else{
    dp[0][S.at(0)-'0'] = 1;
  }
 
  for( int i = 1; i < S.size(); i++ ){
    if( S.at(i) == '?' ){
      for( int num = 0; num < 10; num++ ){
        for( int j = 0; j < 13; j++ ){ //前のあまり
          dp[i][(j*10+num)%13] += dp[i-1][j];
          dp[i][(j*10+num)%13] %= MOD;
        }
      }
    }else{
      for( int j = 0; j < 13; j++ ){
        int num = S.at(i)-'0';
        dp[i][(j*10+num)%13] += dp[i-1][j];
        dp[i][(j*10+num)%13] %= MOD;
      }
    }
  }
  cout << dp[S.size()-1][5] << endl;
  
}


Measured memory_bytes: 13696
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, m = MAP()
ml = -1
mr = n
for _ in range(m):
    l, r = MAP()
    ml = max(ml, l)
    mr = min(mr, r)
print(max(mr - ml + 1, 0))

Measured memory_bytes: 5148
def s():
 import sys
 r=sys.stdin.readline
 for e in iter(r,'0\n'):
  R=[[]for _ in[0]*-~int(e)]
  for _ in[0]*int(r()):
   a,b=map(int,r().split())
   R[a]+=[b];R[b]+=[a]
  for m in R[1][:]:R[1]+=R[m]
  print(len({*R[1]}-{1}))
if'__main__'==__name__:s()


Measured memory_bytes: 6300
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 1001001001;
  rep(i,n-k+1) {
    ans = min(ans,min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[i])));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

bool is_power(ll x){
  bool f = true;
  while (x > 1){
    if (x % 2 == 1){
      f = false;
      break;
    }
    x /= 2;
  }
  return f;
}

int main(){
  ll H;
  cin >> H;
  ll depth = ceil(log2(H));
  if (is_power(H)){
    depth += 1;
  }
  cerr << depth << " " << log2(H) << endl;
  ll sum = 0;
  for (int i=0; i<depth; i++){
    sum += pow(2, i);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 512
// {{{ Template
// Author:  wenxing
// Date:    2017-12-30 21:04 +0800
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r; i >= l; --i)
#define repv(ele, vec) for (auto &ele : vec)
#define zero(mem) memset(mem, 0, sizeof(mem))
#define sd(_) scanf("%d", &_)
#define sdd(_, __) scanf("%d%d", &_, &__)
#define sddd(_, __, ___) scanf("%d%d%d", &_, &__, &___)
#define sdddd(_, __, ___, ____) scanf("%d%d%d%d", &_, &__, &___, &____)
#define sl(_) scanf("%ld", &_)
#define sll(_, __) scanf("%ld%ld", &_, &__)
#define slll(_, __, ___) scanf("%ld%ld%ld", &_, &__, &___)
#define sc(_) scanf("%c", &_)
#define ss(_) scanf("%s", _)
#define mid(a, b) (((a) + (b)) >> 1)
#define lft(x) x << 1
#define rht(x) x << 1 | 1
#define inf 0x3f3f3f3f
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
// }}}

// - Pseudocode -

// {{{ Global Variables
int n, c[510], s[510], f[510];
// }}}

void solve(int p) {
    ll t = 0;
    while (p < n) {
        // t -> next S_p + xF_p
        if (t < s[p])
            t = s[p];
        else if (t % f[p] != 0) {
            int x = (t - s[p]) / f[p];
            t = s[p] + (x + 1) * f[p];
        }
        t += c[p];
        ++p;
    }
    printf("%lld\n", t);
}

int main() {
    sd(n);
    rep(i, 1, n) sddd(c[i], s[i], f[i]);
    rep(i, 1, n + 1) solve(i);
    return 0;
}


Measured memory_bytes: 256
import math
A, B,H,M = map(int, input().split())
a=math.pi*2*(H/12)+math.pi*2*(5/60)*(M/60)
b=math.pi*2*(M/60)
Ma=max(a,b)
mi=min(a,b)
kaku=Ma-mi
print((A**2+B**2-2*A*B*math.cos(kaku))**(1/2))

Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define intt int64_t

int main() {
    string s, ans;
    cin >> s;
    if(s=="Sunny") ans="Cloudy";
    if(s=="Cloudy") ans="Rainy";
    if(s=="Rainy") ans="Sunny";
    cout << ans << endl;
}

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

const int INF = 1001001001;

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> is(26);
    rep(i,n) is[s[i]-'a'].insert(i);
    rep(qi,q) {
        int ty;
        cin >> ty;
        if (ty == 1) {
            int i; char c;
            cin >> i >> c;
            i--;
            is[s[i]-'a'].erase(i);
            s[i] = c;
            is[s[i]-'a'].insert(i);
        }
        if (ty == 2) {
            int l, r;
            cin >> l >> r;
            l--;
            int ans = 0;
            rep(i,26) {
                auto iter = is[i].lower_bound(l);
                if (iter != is[i].end() && *iter < r) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 27264
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N);
    
    REP(i,N) cin >> A[i];
    
    for(int i = 0; i < N; ++i){
        B[i] = A[i] + i;
        C[i] = -A[i] + i;
    }
    
    map<ll, ll> mp;
    ll ans = 0;
    for(int i = 0; i < N; ++i){
        ll tmp = mp[C[i]];
        ans += tmp;
        mp[B[i]]++;
    }
    
    cout << ans << endl;
}




int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 30328
// Libraries
fun string(): String = readLine()!!
fun int(): Int = readLine()!!.toInt()
fun long(): Long = readLine()!!.toLong()
fun stringList(): List<String> = readLine()!!.split(" ")
fun intList(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun longList(): List<Long> = readLine()!!.split(" ").map(String::toLong)

// 最大公約数(ユーグリットの互除法)
tailrec fun gcd(a: Int, b: Int): Int = when {
    a < b -> gcd(b, a)
    b == 0 -> a
    else -> gcd(b, a % b)
}

fun min(a: Int, b: Int): Int = if(a < b) a else b
fun min(a: Long, b: Long): Long = if(a < b) a else b
fun max(a: Int, b: Int): Int = if(a > b) a else b
fun max(a: Long, b: Long): Long = if(a > b) a else b

fun main(args: Array<String>) {
    var head = mutableListOf<Char>()
    var tail = string().toMutableList()
    val Q = int()
    repeat(Q) {
        val query = string().split(" ")
        val T = query[0].toInt()
        if(T == 1) {
            val tmp = head
            head = tail
            tail = tmp
        }else{
            val F = query[1].toInt()
            val C = query[2].first()
            if(F == 1) {
                head.add(C)
            }else{
                tail.add(C)
            }
        }
    }

    val res = head.joinToString("").reversed() + tail.joinToString("")
    println(res)
}

Measured memory_bytes: 76740
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
N = int(input())
s = input().strip()
r = 0
b = 0

for i in range(0, len(s)):
    if s[i] == 'R':
        r += 1
    else:
        b += 1

if r > b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
N=int(input())

P= [tuple(map(int,input().split())) for i in range(N)]


from math import sqrt
def d(p1,p2):
    x1,y1=p1
    x2,y2=p2
    return sqrt((x1-x2)**2 + (y1-y2)**2)

s=0
n=0

import itertools
from functools import reduce
for p in itertools.permutations(P):
    s += sum( [ d(p[i],p[i+1]) for i in range(N-1) ] )
    n+=1
print(s/n)


Measured memory_bytes: 42732
h, w, m = map(int, input().split())
target_points = {tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)}

row_points = [0] * h
col_points = [0] * w
for row, col in target_points:
    row_points[row] += 1
    col_points[col] += 1

row_max = max(row_points)
col_max = max(col_points)

row_max_indexes = [i for i in range(h) if row_points[i] == row_max]
col_max_indexes = [i for i in range(w) if col_points[i] == col_max]

crossing_filled = len(row_max_indexes) * len(col_max_indexes) <= m and \
                  all([(row, col) in target_points for row in row_max_indexes for col in col_max_indexes])

print(row_max + col_max - crossing_filled)


Measured memory_bytes: 83620
#include<stdio.h>
#include<stdlib.h>

int del_Recipies(int del,int count,int n,int m,int p[],int Recipies[500][500]);

int main()
{
	int n,m,Recipies[500][500]={0},MAX[500],min_del_Recipies,c,flag,*p,count;
	
	while(1)
	{
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		min_del_Recipies=-1;
		for(int i=0;i<m;i++) MAX[i]=0;
		for(int i=0;i<n;i++)
		{
			for(int t=0;t<m;)
			{
				Recipies[i][t]=getchar();
				if(Recipies[i][t] != '\n'&& Recipies[i][t] != ' ')
				{
					Recipies[i][t]-='0';
					MAX[t]+=Recipies[i][t];
					t++;
				}
			}
		}
		flag=1;
		//作る際に必要な材料数がすべての材料で2で割り切れたなら、その時のレシピ数になる
		for(int t=0;t<m;t++)
		{
			if(MAX[t]%2)
			{
				flag=0;
				break;
			}
		}
		if(flag) min_del_Recipies=0;
		else
		{
			p=(int*)malloc(m*sizeof(int));
			//すべて作った時に必要な材料からレシピを減らしていく
			//減らしていく数を順に増やしていき、その減らす数の時のすべての減らし方を試す
			
			for(int del=1;del<n;del++)//何個引くか del個 引いた個数 count
			{
				for(int i=0;i<m;i++) p[i]=MAX[i];
				count=0;
				flag=del_Recipies(del,count,n,m,p,Recipies);//何個引くか del個 引いた個数 count
				//del個減らしたときにすべての材料が2で割り切れるものがあったら 1を返す なかったら 0を返す
				if(flag)
				{
					min_del_Recipies = del;//delで割り切れたとき
					break;
				}
			}
			if(min_del_Recipies==-1)min_del_Recipies=n;//どれも割り切れなかったとき
			free(p);
		}
		printf("%d\n",n-min_del_Recipies);//全体から割り切れるまでに引いた個数を引くと求まる
	}
	return 0;
}

int del_Recipies(int del,int count,int n,int m,int p[],int Recipies[500][500])
{
	//引く個数=del 引いた個数=count何種類目 i
	int flag=1;
	for(;count<n && n-count>=del;count++)
	{
		
		if(del==1)
		{
			flag=1;
			for(int t=0;t<m;t++)
			{
				p[t]-=Recipies[count][t];
				if(p[t]%2!=0)
				{
					flag=0;
					p[t]+=Recipies[count][t];
					break;
				}
				p[t] += Recipies[count][t];
			}
			if(flag) return 1;
			else continue;
		}
		else 
		{
			//残りの引く個数が1になるまで再起
			//pから今回引くRecipiesを引いてから次に渡す
			for(int t=0;t<m;t++) p[t]-=Recipies[count][t];
			//引く個数delを一つ減らす　引いた個数countを一つ増やす
			if(del_Recipies(del-1,count+1,n,m,p,Recipies)) return 1;
			for (int t = 0; t<m; t++) p[t] += Recipies[count][t];
		}
		
	}
	return 0;
}


Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if ( a + b > c + d ) {
    cout << "Left" << endl;
  } else if ( a + b < c + d ) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<queue>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[8],c[30][256],m,n,o,u,v,x,y;
  unsigned b[30][30];
  double z;
  priority_queue<pair<double,pair<int,int> >,vector<pair<double,pair<int,int> > >,greater<pair<double,pair<int,int> > > > e;
  while(cin>>m>>n>>o>>u>>v&&m+n+o+u+v){
    u--;
    v--;
    for(i=0;i<m;i++)
      cin>>a[i];
    memset(b,-1,sizeof(b));
    for(i=0;i<o;i++){
      int p,q,r;
      cin>>p>>q>>r;
      p--;
      q--;
      b[p][q]=b[q][p]=r;
    }
    memset(c,-1,sizeof(c));
    while(e.empty()==0)
      e.pop();
    e.push(make_pair(0,make_pair(u,0)));
    while(e.empty()==0){
      z=e.top().first;
      x=e.top().second.first;
      y=e.top().second.second;
      if(x==v)
	break;
      e.pop();
      if(c[x][y]==-1){
	c[x][y]=1;
	for(i=0;i<m;i++){
	  if((y&(1<<i))==0){
	    for(j=0;j<n;j++){
	      if((int)b[x][j]!=-1)
		e.push(make_pair(z+(double)b[x][j]/a[i],make_pair(j,y|(1<<i))));
	    }
	  }
	}
      }
    }
    if(e.empty())
      cout<<"Impossible"<<endl;
    else
      cout<<z<<endl;
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int main(void)
{
	string s;
	cin >> s;
	char c = s[0];
	int count = 0;
	Rep(i, s.length()){
		if(s[i] != c){
			c = s[i];
			count++;
		}
	}
	PrintLn(count);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};

string s[50];
int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) cin >> s[i];
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (s[y][x] == '#') {
        cout << '#';
        continue;
      }
      int c = 0;
      for (int i = 0; i < 8; i++) {
        int a = x + dx[i], b = y + dy[i];
        c += 0 <= a && a < w && 0 <= b && b < h && s[b][a] == '#';
      }
      cout << c;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

tmp=a[-1]
ans=0
for i in range(n-1):
    ii=n-i-2
    #print(ii)
    ans+=(tmp*a[ii])%mod
    ans=ans%mod
    tmp+=a[ii]%mod

print(ans%mod)


    



Measured memory_bytes: 94268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
const ll mod = 1e9 + 7;
int main(){
    int n; cin >> n;
    vector<vector<double> > dp(n+1, vector<double>(n+1, 0));
    dp[0][0] = 1;
    rep(i,n){
        double p; cin >> p;
        rep(j,n+1){
            if(j == 0)dp[i+1][j] = dp[i][j]*(1 - p);
            else dp[i+1][j] = dp[i][j-1]*p + dp[i][j]*(1 - p);
        }
    }

    //rep(i,n+1)rep(j,n+1)cout << dp[i][j] << ((j < n)?" ":"\n");
    double r = 0;
    REP(i,(n+2)/2,n+1)r += dp[n][i];
    printf("%.12f\n", r);
    return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  double R; cin >> R;
  cout << 2.0*M_PI*R << endl;
  return 0;
}


Measured memory_bytes: 3800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0202
{
    public class Program

    {
        public static void Main(string[] args)
        {
            bool[] primes = new bool[1000001];
            for (int i = 0 ; i < primes.Length ; i++) if (IsPrime(i)) primes[i] = true;

            while (true)
            {
                int[] nx = RIntAr();
                if (nx.Sum() == 0) break;

                int[] dish = new int[nx[0]];
                for (int i = 0 ; i < dish.Length ; i++) dish[i] = RInt();

                bool[] combination = new bool[nx[1] + 1];
                combination[0] = true;

                for (int i = 0 ; i < combination.Length ; i++)
                {
                    if (combination[i])
                    {
                        for (int j = 0 ; j < dish.Length ; j++)
                        {
                            if (i + dish[j] < combination.Length) combination[i + dish[j]] = true;
                        }
                    }
                }

                Console.WriteLine(GetRes(primes, combination));
            }
        }

        private static string GetRes(bool[] primes, bool[] combination)
        {
            for (int i = combination.Length - 1 ; i >= 1 ; i--)
            {
                if (primes[i] && combination[i])
                {
                    return i.ToString();
                }
            }
            return "NA";
        }

        /// <summary>
        ///素数判定
        /// </summary>
        public static bool IsPrime(long number)
        {
            long boundary = (long)Math.Floor(Math.Sqrt(number));

            if (number == 1) return false;
            if (number == 2) return true;

            for (long i = 2 ; i <= boundary ; ++i)
            {
                if (number % i == 0) return false;
            }
            return true;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 36520