akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng { using namespace boost; using namespace boost::range; }
namespace adp { using namespace boost::adaptors; }

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> snk(n);
    for (int i : irange(k)) {
        int d;
        cin >> d;
        for (int j : irange(d)) {
            int a;
            cin >> a;
            snk[a-1]++;
        }
    }
    int ans = 0;
    for (int x : snk) {
        if (x == 0) ans++;
    }
    cout << ans << nl;
}


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

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

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

void Main() {
	int a, b;
	char op;
	while (true) {
		cin >> a >> op >> b;
		if (op == '?') break;
		switch (op)
		{
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		default:
			break;
		}
	} 
}

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



Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <cmath>

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

const long long INF = 1LL << 60;

long long h[100010];
long long dp[100010];

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

  for (int i = 0; i < 100010; ++i) {
    dp[i] = INF;
  }

  dp[0] = 0;
  for (int i = 1; i < N; ++i) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }

  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    double n,t=0;
    cin>>n;
    vector<double> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
        t+=a[i];
    }
    double p=t/n,m=LLONG_MAX,mi;
    for(ll i=n-1;i>=0;--i){
        double tt=abs(a[i]-p);
        if(tt<=m){
            m=tt;
            mi=i;
        }
    }
    cout<<mi;
}


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

using namespace std;
class dsu {
public:
  vector<int> rank, p, size;
  dsu(){};
  dsu(int n) {
    rank.assign(n, 0);
    size.assign(n, 1);
    p.resize(n);
    for (int i = 0; i < n; ++i) p[i] = i;
  }

  int getSize(int x) {
    return size[findRep(x)];
  }
  
  void unite(int x, int y) {
    int p1 = findRep(x), p2 = findRep(y);
    if (p1 == p2) return;
    if (rank[p1] < rank[p2]) swap(p1, p2);

    if (rank[p1] == rank[p2]) rank[p1]++;
    p[p2] = p1;
    size[p1] += size[p2];
  }

  int findRep(int x) {
    if ( x != p[x] ) {
      p[x] = findRep(p[x]);
    }
    return p[x];
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  int x, y, z;
  dsu *d = new dsu(N);
  for (int i = 0; i < M; ++i) {
    cin >> x >> y >> z;
    d->unite(--x, --y);
  }
  set<int> ans;
  for (int i = 0; i < N; ++i) {
    ans.insert(d->findRep(i));
  }
  cout << ans.size() << endl;
  return 0;
}



Measured memory_bytes: 6144
#include <stdio.h>
int main(){
  int n,i,x;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    x=i;
    if(x%3==0){
      printf(" %d",x);
    }
    else{
      while(x){
      if(x%10==3){ 
    printf(" %d",i);
        break;
      }
      x=x/10;
      }
    }
  }
    printf("\n");
  return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int ans;
int main(void){
    int a,b; cin>>a>>b;
    if(a<=9&&b<=9){
        cout<<a*b<<endl;
    }else{
        cout<<-1<<endl;
    }
    
}


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

using namespace std;

int main(){
    int n,q;
    cin >> n;
    int S[n];
    rep(i, n) cin >> S[i];
    cin >> q;
    int T[q];
    rep(i, q) cin >> T[i];
    
    int cnt = 0;
    for(int i=0; i<q; i++) {
        int t = T[i];
        for(int j=0; j<n; j++) {
            if(t == S[j]) {
                cnt++;
                break;
            }
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 3120
A,B = map(int,input().split())
l = B - A + 1
if A % 2 == 0:
    if l % 2 == 0:
        if l % 4 == 0:
            ans = 0
        else:
            ans = 1
    elif (l-1) % 4 == 0:
        ans = B
    else:
        ans = B^1
else:
    if l % 2 == 0:
        if (l-2) % 4 == 0:
            ans = A^B
        else:
            ans = A^B^1
    elif (l-1) % 4 == 0:
        ans = A
    else:
        ans = A^1
if A == B:
    ans = A

print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string a;
  R a;
  rep(t,1<<3) {
    ll sum=a[0]-'0';
    rep(i,3) {
      if(t&(1<<i)) sum+=a[i+1]-'0';
      else sum-=a[i+1]-'0';
    }
    if(sum==7) {
      rep(i,4) {
        cout << a[i];
        if(i!=3) {
          if(t&(1<<i)) cout << "+";
          else cout << "-";
        }
      }
      cout << "=7" << endl;
      return;
    }
  }
}

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


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

using namespace std;

int main()
{
int A,B ;
cin >> A>>B;
if (A <= 5)
    cout << 0 ;
else if (A>=6 && A<=12 )
    cout << B/2 ;
else if (A>=13)
    cout << B ;








    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

typedef struct{
	double x;
	double y;
}point;

void kock(int n,point p1,point p2){
	if(n==0) return;
	point s,t,u;
	s.x=(2*p1.x+1*p2.x)/3;
	s.y=(2*p1.y+1*p2.y)/3;
	t.x=(1*p1.x+2*p2.x)/3;
	t.y=(1*p1.y+2*p2.y)/3;
	u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
	u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;

	kock(n-1,p1,s);
	printf("%lf %lf\n",s.x,s.y);
	kock(n-1,s,u);
	printf("%lf %lf\n",u.x,u.y);
	kock(n-1,u,t);
	printf("%lf %lf\n",t.x,t.y);
	kock(n-1,t,p2);
}

int main(void){
	int n;
	point p1={0,0},p2={100,0};
	scanf("%d",&n);
	printf("%lf %lf\n",p1.x,p1.y); 
	kock(n,p1,p2);
	printf("%lf %lf\n",p2.x,p2.y);
	return 0;
}

Measured memory_bytes: 636
#include<stdio.h>

int main(void)
{
	int a, b, c, i, key;
	key = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(i = a; i <= b; i++){
		if(c % i == 0){
			key++;
		}
	}
	printf("%d\n", key);
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

int main()
{
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  
  int ans = INF;

  for(int bit = 0; bit < 1<<(2*n); ++bit) {
    int aa = 0, bb = 0, cc = 0;
    int cost = 0;

    rep(i, n) {
      bool f1 = bit&(1<<(2*i)), f2 = bit&(1<<(2*i+1));
      if(!f1 && !f2) continue;
      cost += 10;
      if(f1 && !f2) aa += l[i];
      if(!f1 && f2) bb += l[i];
      if(f1 && f2) cc += l[i];
    }

    //cout << aa << " " << bb << " " << cc << endl;
    if(aa == 0 || bb == 0 || cc == 0) continue;
    cost += abs(aa-a) + abs(bb-b) + abs(cc-c);
    cost -= 30;
    chmin(ans, cost);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut opens = HashMap::<Vec<usize>, usize>::new();
    for _i in 0..n {
        let s = read::<String>().chars().collect::<Vec<char>>();
        let mut item = vec![0; 128];
        for j in 0..s.len() {
            item[s[j] as u8 as usize] += 1;
        }
        let entry = opens.entry(item).or_insert(0);
        *entry += 1;
    }
    let mut ans = 0;
    for v in opens.values() {
        ans += v * (v - 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 112892
#include <stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
#define INF 100000000
#define min(a,b) (a<b?a:b)
int main(){
	int i,j,k,n,m,bit,next,cur,r,newCost,ret;
	int land[200][200] , ship[200][200] , R[1000] ,dp[2][200];
	while(scanf("%d%d",&n,&m) && n){
		rep(i,n)rep(j,n)land[i][j] = ship[i][j] = INF;
		rep(i,n)land[i][i] = ship[i][i] = 0;
		
		rep(i,m){
			char t;
			int a,b,c;
			scanf("%d %d %d %c\n",&a,&b,&c,&t);
			a--,b--;
			if(t=='L')land[a][b] = land[b][a] = min(c,land[a][b]);
			else  ship[a][b] = ship[b][a] = min(c,ship[a][b]);
		}
		rep(k,n)rep(i,n)rep(j,n)land[i][j] = min(land[i][j],land[i][k]+land[k][j]);
		rep(k,n)rep(i,n)rep(j,n)ship[i][j] = min(ship[i][j],ship[i][k]+ship[k][j]);
		
		scanf("%d",&r);	
		rep(i,r)scanf("%d",&R[i]) , R[i]--;
		
		rep(j,2)rep(k,n)dp[j][k] = INF;
		dp[0][R[0]] = 0;
		
		rep(bit,r-1){
			rep(cur,n){
				rep(next,n){
					newCost = dp[bit%2][cur] + land[R[bit]][cur] + ship[cur][next] + land[next][R[bit+1]];
					dp[(bit+1)%2][next] = min( dp[(bit+1)%2][next],newCost);
				}
				dp[(bit+1)%2][cur] = min(dp[(bit+1)%2][cur],dp[bit%2][cur]+land[R[bit]][R[bit+1]]);
			}
			rep(j,n)dp[bit%2][j] = INF;
		}
		ret = INF;
		rep(i,n)ret = min(dp[(r-1)%2][i],ret);
		printf("%d\n",ret);
	}
	return 0;
}

Measured memory_bytes: 732
#include <stdio.h>

#define inf 1e9
#define max 150
#define min(a,b) ((a) < (b) ? (a) : (b))

int main(){
  int n,i,u,k,j,v,c;
  int d[max][max];

  for(i=0;i<max;i++){
    for(j=0;j<max;j++){
      d[i][j] = inf;
    }
    d[i][i] = 0;
  }
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      d[u][v] = c;
    }
  } 

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

  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[0][i]);
  }

  return 0;
}



Measured memory_bytes: 2108
n,d=map(int,input().split())
A=[[0 for i in range(d)]for j in range(n)]
for i in range(n):
    A[i]=list(map(int,input().split()))
count=0
for i in range(n-1):
    for j in range(i+1,n):
        s=0
        for k in range(d):
            s=s+(A[i][k]-A[j][k])**2
        if (int(s**(1/2)))**2==s:
            count+=1
print(count)

Measured memory_bytes: 3064
H, W, K = map(int, input().split())
s = [list(input()) for i in range(H)]

ans = [[-1]*W for i in range(H)]
pieces = [False]*H

for i in range(H):
    if "#" in s[i]:
        pieces[i] = True

count = 0
for i in range(H):
    if pieces[i] == False:
        continue
    flag = False
    count += 1

    for j in range(W):
        if s[i][j] == "#":
            if flag:
                count += 1
            else:
                flag = True

        ans[i][j] = count
count = 0
for i in range(H):
    if pieces[i] == False:
        count += 1
    else:
        for k in range(count):
            for j in range(W):
                ans[i-k-1][j] = ans[i][j]
        count = 0
count = 0
for i in reversed(range(H)):
    if pieces[i] == False:
        count += 1
    else:
        for k in range(count):
            for j in range(W):
                ans[i+k+1][j] = ans[i][j]
        break

for i in range(H):
    print(" ".join(map(str, ans[i])))


Measured memory_bytes: 7924
# 二つの整数 A , B が入力されます。 A + B の値を出力してください。
# ただし、 A + B が 10 以上の場合は、代わりに error と出力してください。

A,B = map(int,input().split())

if A + B <= 9:
    print(A + B)

else:
    print('error')

Measured memory_bytes: 9152
import itertools
import math
k = int(input())
lst = list(itertools.combinations_with_replacement(range(1, k+1), 3))
ans = 0
for i in range(len(lst)):
    tmp = math.gcd(lst[i][0], lst[i][1])
    tmp = math.gcd(tmp, lst[i][2])
    if len(set(lst[i])) == 1:
        ans += tmp
    elif len(set(lst[i])) == 2:
        ans += tmp*3
    elif len(set(lst[i])) == 3:
        ans += tmp*6

print(ans)

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

typedef long long ll;

ll N;
map<ll, ll> C;
ll R;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    for (ll d : {-1, 0, 1}) ++C[a - d];
  }
  for (auto xc : C) R = max(R, xc.second);
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 6144
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
typedef unsigned char uc;
const ll MAX_H=185,MAX_W=185,MAX_LOG_HW=16;
int H,W;
string A[MAX_H];
uc dpw[MAX_H][MAX_H+1][MAX_W+1][MAX_LOG_HW+1],dph[MAX_W][MAX_W+1][MAX_H+1][MAX_LOG_HW+1];
bool cmp(ll i1,ll i2,ll j1,ll j2,ll k){
	//complexityがk以下かどうか
	ll w=dpw[i1][i2][j1][k-1];
	if(w+dpw[i1][i2][j1+w][k-1]>=j2-j1){
		return true;
	}
	ll h=dph[j1][j2][i1][k-1];
	if(h+dph[j1][j2][i1+h][k-1]>=i2-i1){
		return true;
	}
	return false;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>H>>W;
	REP(i,H)cin>>A[i];
	for(ll i=H-1;i>=0;i--)for(ll j=W-1;j>=0;j--){
		if(j<W-1&&A[i][j]==A[i][j+1])dpw[i][i+1][j][0]=dpw[i][i+1][j+1][0]+1;
		else dpw[i][i+1][j][0]=1;
		if(i<H-1&&A[i][j]==A[i+1][j])dph[j][j+1][i][0]=dph[j][j+1][i+1][0]+1;
		else dph[j][j+1][i][0]=1;
	}
	REP(i1,H){
		FOR(i2,i1+2,H+1){
			REP(w,W){
				if(dph[w][w+1][i1][0]>=i2-i1){
					dpw[i1][i2][w][0]=min(dpw[i1][i2-1][w][0],dpw[i2-1][i2][w][0]);
				}else{
					dpw[i1][i2][w][0]=0;
				}
			}
		}
	}
	REP(i1,W){
		FOR(i2,i1+2,W+1){
			REP(h,H){
				if(dpw[h][h+1][i1][0]>=i2-i1){
					dph[i1][i2][h][0]=min(dph[i1][i2-1][h][0],dph[i2-1][i2][h][0]);
				}else{
					dph[i1][i2][h][0]=0;
				}
			}
		}
	}
	FOR(k,1,MAX_LOG_HW+1){
		REP(i1,H){
			FOR(i2,i1+1,H+1){
				ll j2=0;
				REP(j1,W){
					while(j2<W&&cmp(i1,i2,j1,j2,k))j2++;
					if(!cmp(i1,i2,j1,j2,k)){
						j2--;
					}
					dpw[i1][i2][j1][k]=j2-j1;
					if(j2==j1)j2++;
				}
			}
		}
		REP(j1,W){
			FOR(j2,j1+1,W+1){
				ll i2=0;
				REP(i1,H){
					while(i2<H&&cmp(i1,i2,j1,j2,k))i2++;
					if(!cmp(i1,i2,j1,j2,k)){
						i2--;
					}
					dph[j1][j2][i1][k]=i2-i1;
					if(i2==i1)i2++;
				}
			}
		}
	}
	ll ans=0;
	REP(k,MAX_LOG_HW+1){
		if(dpw[0][H][0][k]>=W||dph[0][W][0][k]>=H){cout<<k<<endl;break;}
	}
//	cout<<dpw[0][H-1][0][0]<<endl;
}

Measured memory_bytes: 211328
#include<stdio.h>
int main()
{
    double a,b,c,d,e,f,g,h,i,j;
    while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF)
    {
        g=(c*e)-(b*f);
        h=(a*e)-(b*d);
        i=(f*a)-(d*c);
        j=(e*a)-(b*d);
        if(g/h == -0.000)printf("0.000 %.3lf\n",i/j);
        else if(i/j == -0.000)printf("%.3lf 0.000\n",g/h);
        else printf("%.3lf %.3lf\n",(g/h),(i/j));
    }
    return 0;
}

Measured memory_bytes: 652
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
import numpy as np
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

def main():
    n = II()
    aa = MII()
    if n == 2: print(*aa); exit(0)
    aa.sort()
    maxa = aa[-1]
    m = maxa/2
    a = getNearestValue(aa, m)
    print(maxa, a, end= ' ')

if __name__ == '__main__':
    main()


Measured memory_bytes: 23128
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 100000000
#define mod 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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;
}

int N;
int a[110000];
ll int res[110000];

int main () {
  cin >> N;
  Rep(i, N) cin >> a[i];

  ll int sum = 0;
  Rep(i, N) sum += a[i];

  ll int tmp = 0;
  for (int i=1;i<N;i+=2) {
    tmp += 2 * a[i];
  }
  res[0] = sum - tmp;

  tmp = 0;
  for (int i=2;i<N;i+=2) {
    tmp += 2 * a[i];
  }
  res[1] = sum - tmp;

  for (int k=2;k<N;++k) {
    res[k] = res[k-2] + 2 * (a[k-1] - a[k-2]);
  }

  Rep(i, N-1) {
    cout << res[i] << " ";
  }
  cout << res[N-1] << "\n";

}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int r;
    r = x/500;
    r = (r*1000);
    x = x%500;
    int y = x/5;
    y = 5*y;
    r = r+y;
    cout<<r<<"\n";
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  bool easy = true;
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='L'&&i%2==0) easy = false;
    if(S[i]=='R'&&i%2==1) easy = false;
  }
  if(easy) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b)
#define mins(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

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

    int tmp;
    rep(b,100)rep(c,50)rep(d,34)rep(e,25)rep(f,20){
        tmp=101*b+102*c+103*d+104*e+105*f;
        if(tmp%100 == x%100 && tmp<=x && (tmp-x)%100==0){
            cout<<1<<endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define re register
#define FOR(i,a,b) for(re int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(re int i=(a);i>=(b);i--)
#define temT template<typename T>
using namespace std;
typedef long long ll;

int main(){
	int n,cur=0;
	const int a=int(1e3);
	cin>>n;
	while(cur<n) cur+=a;
	cout<<cur-n;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

 
int main() {
    double l;
    cin>>l;
    
    cout<<setprecision(10)<<l*l*l/27<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
	while(cin >> n) {
		if(n <= 0 || n > 50) continue;
		int ret = 0;
		for(int i = 0; i <= 9; i++) {
			for(int j = 0; j <= 9; j++) {
				for(int k = 0; k <= 9; k++) {
					for(int l = 0; l <= 9; l++) {
						if(i + j + k + l == n) ret++;
					}
				}
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 3128
#include <cstdio>
#include <set>

using namespace std;

int main() {
    int a, b, k;
    set<int> se;
    scanf("%d %d %d", &a, &b, &k);
    for (int i = a; i < a + k; i++) {
        if (i > b ) break;
        se.insert(i);
    }
    for (int i = b; i > b - k; i--) {
        if (i < a) break;
        se.insert(i);
    }
    set<int>::iterator pos = se.begin();
    while(pos != se.end()) {
        printf("%d\n", *pos);
        pos++;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



int main()
{
        string S;
        cin >> S;
        ll ans = count(all(S), '1');
        cout << ans << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main() {
	double a,b,t;
	scanf("%lf%lf%lf",&a,&b,&t);
	
	double s=0.5*a*b*sin(t/180.0*PI);
	double c=sqrt(a*a+b*b-2*a*b*cos(t/180.0*PI));
	double l=a+b+c;
	double h=s*2/a;
	
	printf("%lf %lf %lf\n",s,l,h);
	return 0;
}

Measured memory_bytes: 2940
import math

class Point():
    def __init__(self, __x, __y):
        self.__x = __x
        self.__y = __y
    
    def get_x(self):
        return self.__x
    
    def get_y(self):
        return self.__y

def dist(__p1, __p2):
    __dist_x = abs(__p2.get_x() - __p1.get_x())
    __dist_y = abs(__p2.get_y() - __p1.get_y())
    return math.sqrt(__dist_x ** 2 + __dist_y ** 2)

str = input().split()
x1, y1, x2, y2 = [float(i) for i in str]
p1 = Point(x1, y1)
p2 = Point(x2, y2)
print(dist(p1, p2))


Measured memory_bytes: 5664
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8


def run():
    N, T , *A = map(int, read().split())
    max_gap = 0
    current_min = (INF, -1)
    pairs = set()
    if A[0] > A[1]:
        down = True
    else:
        down = False
        current_min = (A[0], 0)

    for i in range(N-1):
        if down:
            if A[i] < A[i+1]:
                if current_min[0] > A[i]:
                    current_min = (A[i], i)
                down = False
        else:
            if A[i] > A[i+1]:
                down = True
                gap = A[i] - current_min[0]
                if max_gap == gap:
                    pairs.add((current_min[1], i))
                elif max_gap < gap:
                    max_gap = gap
                    pairs = set()
                    pairs.add((current_min[1], i))
                else:
                    continue
    if not down:
        gap = A[N-1] - current_min[0]
        if max_gap == gap:
            pairs.add((current_min[1], N-1))
        elif max_gap < gap:
            max_gap = gap
            pairs = set()
            pairs.add((current_min[1], N-1))
    print(len(pairs))


if __name__ == "__main__":
    run()

Measured memory_bytes: 22188
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, x;
    std::cin >> n >> x;
    int d = 0;
    for (int i = 0; i < n; i++) {
        int l;
        std::cin >> l;
        d += l;
        if (d > x) {
            std::cout << i + 1 << std::endl;
            return 0;
        }
    }
    std::cout << n + 1 << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
using ll=long long;
int main(){
  ll n, k;
  cin >> n >> k;
  ll a[n];
  for(ll i=0; i<n; i++){
    cin >> a[i];
  }
  vector<ll> v;
  set<ll> s;
  v.push_back(0);
  s.insert(0);
  ll loop, ls=0;
  ll c=0, i=0;
  while(1){
    if(s.count(a[i]-1)==1) {ls=a[i]-1; loop=c+1; break;}
    else {v.push_back(a[i]-1); s.insert(a[i]-1);}
    if(c+1==k){loop=c+1; break;}
    i=a[i]-1;
    c++;
  }
  if(ls!=0){
    ll p;
    for(p=0; p<v.size(); p++){
      if(ls==v[p]) {break;}
    }
    loop-=p;
    vector<ll> w;
    for(ll i=p; i<v.size(); i++) w.push_back(v[i]);
    cout << w[(k-p)%loop]+1;
  }
  else if(c+1==k) cout << v[k]+1;
  else cout << v[k%loop]+1;
  return 0;
}

Measured memory_bytes: 15092
from sys import stdin
import copy

def output(string, lis):
    for num in lis:
        print(string, num)

n = int(stdin.readline())

#ナンバーリスト作成
slist = []
for i in range(1,14):
    slist.append(i)

hlist = copy.copy(slist)
clist = copy.copy(slist)
dlist = copy.copy(slist)

for _ in range(n):
    mark, number = map(str, stdin.readline().split())
    if mark == 'S':
        slist.remove(int(number))
    elif mark == 'H':
        hlist.remove(int(number))
    elif mark == 'C':
        clist.remove(int(number))
    elif mark == 'D':
        dlist.remove(int(number))

output('S', slist)
output('H', hlist)
output('C', clist)
output('D', dlist)


Measured memory_bytes: 6336
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//
int main() {
	int N, M;
	cin >> N >> M;
	
	Vec< int > root(N);
	for_(i,0,N) root[i] = i;
	
	Vec< set< pii > > group(N);
	for_(i,0,N) {
		int a; 
		cin >> a;
		group[i].insert(pii(a, i));
	}
	
	auto merge = [&](int i, int j) {
		int ri = root[i], rj = root[j];
		if (ri == rj) return -1;
		if (group[ri].size() > group[rj].size()) swap(ri, rj);
		for (pii p : group[ri]) {
			root[p.second] = rj;
			group[rj].insert(p);
		}
		group[ri] = set< pii >();
		return rj;
	};
	
	for_(i,0,M) {
		int x, y;
		cin >> x >> y;
		merge(x, y);
	}
	
	lint ans = 0;
	Vec< int > deg1;
	for_(i,0,N) if (group[i].size() == 1) deg1.push_back(i);
	
	int deg1_cnt = deg1.size() - 1;
	for_(i,0,deg1_cnt) {
		int v = deg1[i];
		ans += (lint)(*group[v].begin()).first;
		group[v].clear();
	}
	
	set< pii > deg_order;
	for_(i,0,N) if (!group[i].empty()) deg_order.insert(pii(group[i].size(), i));
	
	while (deg_order.size() > 1) {
		pii s = *deg_order.begin();
		pii t = *deg_order.rbegin();
		
		pii gs = *group[s.second].begin();
		pii gt = *group[t.second].begin();
		
		ans += (lint)gs.first + (lint)gt.first;
		
		group[s.second].erase(gs);
		group[t.second].erase(gt);
		
		deg_order.erase(s);
		deg_order.erase(t);
		
		int new_id = merge(s.second, t.second);
		deg_order.insert(pii(group[new_id].size(), new_id));
	}
	
	pii p = *deg_order.begin();
	if (p.first < deg1_cnt) {
		puts("Impossible");
	} else {
		int id = p.second;
		while (deg1_cnt > 0) {
			pii g = *group[id].begin();
			ans += (lint)g.first;
			group[id].erase(g);
			--deg1_cnt;
		}
		cout << ans << endl;
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//


Measured memory_bytes: 10624
H, N  = map(int, input().split())
fs = [] # damage/MP
for i in range(N):
    fs.append(map(int, input().split()))
INF = 10**10
M = 2*10**4+1
dp = [INF]*M
dp[0] = 0
for i,(a,b) in enumerate(fs):
    # update
    for j in range(H):
        # 何回でも使っていい⇛dp[i+1][j]+b
        dp[j+a] = min(dp[j+a], dp[j]+b) 
print(min(dp[H:]))

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

#define ll long long

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

	ll a, b;
	scanf("%lld %lld", &a, &b);
	if (a >= 13)
	{
		printf("%lld\n", b);
	}
	else if (a >= 6 && a <= 12)
	{
		printf("%lld\n", b / 2);
	}
	else
	{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    x -= a;
    int c = x / b;
    cout << x - c * b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,w;
  cin>>n>>w;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];

  const Int MAX = 1e5+100;
  const Int INF = 1e15;
  vector<Int> dp(MAX+1,INF);
  dp[0]=0;
  for(Int i=0;i<n;i++)
    for(Int j=MAX-b[i];j>=0;j--)
      chmin(dp[j+b[i]],dp[j]+a[i]);

  Int ans=0;
  for(Int i=0;i<MAX;i++)
    if(dp[i]<=w) chmax(ans,i);
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    priority_queue<int> que;
    int n,m,t;
    ll ans=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>t;
        que.push(t);
    }
    for(int i=1;i<=m;i++)
    {
        t=que.top();
        que.pop();
        que.push(t/2);
    }
    while(!que.empty())
    {
        t=que.top();
        que.pop();
        ans+=t;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  vector<bool> b(8,false);
  int tuyoi = 0;
  int n; cin >> n;
  rep(i, n){
    int rate; cin >> rate;
    int cnt = 0;
    for(int j=0; j<3200; j+=400){
      if(rate >= 3200){ tuyoi++; break; }
      if(j <= rate && rate < j+400) b[cnt] = true;
      cnt++;
    }
  }
  int iro = 0;
  rep(i, 8){
    if(b[i] == true) iro++;
  }
  if(iro==0)
    cout << 1 << " " << tuyoi << endl;
  else
    cout << iro << " " << iro+tuyoi << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const int MN = 100010;

vector<int> g[MN];
int from[MN], to[MN], cost[MN];
int color[MN];

void dfs(int u, int p) {
    for (int e : g[u]) {
        int v = from[e] + to[e] - u;
        if (v == p) continue;
        if (cost[e] % 2) color[v] = 1 - color[u];
        else color[v] = color[u];
        dfs(v, u);
    }
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	for (int i = 0; i < n - 1; i++) {
        cin >> from[i] >> to[i] >> cost[i];
        from[i]--; to[i]--;
        g[from[i]].push_back(i);
        g[to[i]].push_back(i);
	}
	dfs(0, -1);
	for (int i = 0; i < n; i++)
        cout << color[i] << endl;
	return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

int main() {
    ll N;
    cin >> N;
    string S,T;
    double ans = 0;
    rep(i,N){
        cin >> S >> T;
        if(T == "JPY"){
            ll num = stoll(S);
            ans += num;
        }
        else{
            ld num = stold(S);
            ans += num * 380000;
        }
    }
    printf("%.10f\n", ans);
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,cnt,i;
 scanf("%d %d %d",&a,&b,&c);
 for(i=a,cnt=0;i<=b;cnt+=!(c%i++));
 printf("%d\n",cnt);
 
 return 0;
}



Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using static AtCoderer.Exter;
using System.Linq;

namespace AtCoderer
{

    public class App
    {
        public static void Main(string[] args)
        {
            int i = 0;
            int s = readarr[1]-1;
            foreach (var c in Console.ReadLine())
            {
                if (s == i)
                    Console.Write(char.ToLower(c));
                else
                    Console.Write(c);
                    i++;
            }
            Console.WriteLine();
            Console.ReadLine();
        }
    }
    public static class Exter
    {
        public static void rep(int loop, Action<int> act)
        {
            for (int i = 0; i < loop; i++)
                act(i);
        }
        public static int ToInt(this string v) => int.Parse(v);
        public static int Max(params int[] p) => p.Max();
        public static long Max(params long[] p) => p.Max();
        public static int Min(params int[] p) => p.Min();
        public static long Min(params long[] p) => p.Min();
        public static int Gcd(int a, int b) => a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
        private static int GcdRecursive(int a, int b) => b == 0 ? a : GcdRecursive(b, a % b);
        public static object cout
        {
            set
            {
                Console.Write(value.ToString());
                Console.WriteLine();

            }
        }
        public static void ToCout<t>(this IEnumerable<t> v)
        {
            cout = string.Join(",", v);
        }
        public static int[] readarr
        {
            get
            {
                preadarr = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
                return preadarr;
            }
        }
        public static int[] preadarr;
    }
}


Measured memory_bytes: 13268
using System;

class Program {
    private static int Main() {
        int taro = 0, hanako = 0;

        var input = Console.ReadLine();
        int n = int.Parse( input );

        for( int i = 0; i < n; ++i ) {
            input = Console.ReadLine();
            var values = input.Split( ' ' );

            int compare = string.Compare( values[ 0 ], values[ 1 ] );
            if( compare > 0 ) {
                taro += 3;
            } else if( compare < 0 ) {
                hanako += 3;
            } else {
                ++taro;
                ++hanako;
            }
        }

        var output = string.Format( "{0} {1}", taro, hanako );
        Console.WriteLine( output );

        return 0;
    }
}

Measured memory_bytes: 6392
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int n, m; cin >> n >> m;
	bool key[100010];
	int wcnt[100010];
	REP(i, 100010) {
		key[i] = false;
		wcnt[i] = 0;
	}
	int acnt = 0;
	int Wcnt = 0;
	REP(i, m) {
		int p;
		p--;
		string s;
		cin >> p >> s;
		if (s == "AC") {
			key[p] = true;
		}
		else {
			if (!key[p]) {
				wcnt[p]++;
			}
		}
	}
	REP(i, 100010) {
		if (key[i]) {
			acnt++;
			Wcnt += wcnt[i];
		}
	}
	cout << acnt << " " << Wcnt << endl;
	return 0;
}


Measured memory_bytes: 896
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B = [int(x) for x in input().split()]

    if A >= 1:
        print("Positive")
    elif A * B <= 0:
        print("Zero")
    else:
        if (abs(B) - abs(A) + 1) % 2 == 1:
            print("Negative")
        else:
            print("Positive")

    

if __name__ == '__main__':
    main()



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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define INF 100000000000009
#define mod 1000000007
using namespace std;
typedef long long ll;

int n;
int arr[404];
ll dp[404][404];

ll getsum(int a, int b){
	ll ans = 0;
	for (int i = a; i <= b; i++) ans += arr[i];
	return ans;
}

ll f(int i, int son){
	//cout << "f(" << i << ", " << son << ")" << endl;
	if (i >= son) return 0;
	if (dp[i][son] != -1) return dp[i][son];
 	ll ans = INF;
	for (int k = i+1; k < son; k++){
		ll ans1 = f(i, k) + f(k+1, son);
		ans = min(ans, ans1);
	}
	ans = min(ans, f(i+1, son));
	ans += getsum(i, son);
	return dp[i][son] = ans;
}

int main(){
	//freopen("stl.gir", "r", stdin);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> arr[i];
	}
	
	for (int i = 0; i < 404; i++) for (int j = 0; j < 404; j++) dp[i][j] = -1;
	
 	cout << f(0, n-1) << endl;
	
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void) {
	long long x, y;
	long long button = 0;
	
	scanf("%lld %lld", &x, &y);
	
	if (y == x*-1) button = 1;
	
	if (x < y){
		if (x >= 0 || (x < 0 && y <= 0)) button = y - x;
		else if (x*-1 < y) button = y - x*-1 + 1;
		else button = x*-1 - y + 1;
	}
	else {
		if ((x > 0 && y > 0) || x < 0) button = x - y + 2;
		else if (x == 0) button = y*-1 + 1;
		else if (y == 0) button = x+1;
		else if (x > y*-1) button = x + y + 1;
		else button = x*-1 - y + 1;
	}
	
	printf("%lld\n", button);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<n; i++)
#define per(i, n) for(int i=n-1; i>=0; i--)
#define reps(i, n) for(int i=1; i<n; i++)
#define pers(i, n)  for(int i=n-1; i>=1; i--)

const int INF = 1001001001;

void solve(){
  int n;  cin >> n;
  ll sum = 0;
  reps(i, n+1){
    sum += (i%3==0||i%5==0 ? 0 : i);
  }
  cout << sum << endl;
}

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


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

using namespace std;

#define all(c) c.begin(),c.end()
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& val){
    os << "[ ";
    for(typename vector<T>::const_iterator it=val.begin();
        it != val.end();++it){
        os << *it << " ";
    }
    os << "]";
    return os;
}

ll fact(ll n){
    if(n == 1) return 1;
    else return n * fact(n-1);
}

int main(){
    int n;
    cin >> n;
    cout << fact(n) << endl;
    return 0;
}

Measured memory_bytes: 1156