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

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, X, Y;
  std::cin >> N >> X >> Y;
  --X;
  --Y;

  std::vector<i64> answers(N, 0);
  for (i64 i = 0; i < N - 1; ++i) {
    for (i64 j = i + 1; j < N; ++j) {
      ++answers[std::min(j - i, std::abs(i - X) + 1 + std::abs(j - Y))];
    }
  }

  for (i64 i = 1; i < N; ++i) {
    std::cout << answers[i] << std::endl;
  }
  return 0;
}

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

int main()
{
  int D;
  cin >> D;
  string ans = "Christmas ";
  rep(i, 25 - D)
  {
    ans += "Eve ";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    char c=s.charAt(sc.nextInt()-1);
    for(int i=0;i<n;i++){
      System.out.print(c==s.charAt(i)?c:'*');
    }
    System.out.println();
  }
}

Measured memory_bytes: 35716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <deque>
using namespace std;
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
#define ford(i,a,b) for(int i=(a);i>=(b);--i)
#define min(x,y) ((x) < (y) ? (x) : (y))
#define max(x,y) ((x) < (y) ? (y) : (x))
#define swap(x,y) ((x)^=(y),(y)^=(x),(x)^=(y))
const int maxn=1e6+7;
typedef long long ll;

int read(){
    int s=0,f=1;
    char c=getchar();
    while(c<'0' || c>'9') {if(c=='-') f=-1; c=getchar();}
    while(c>='0' && c<='9') {s=s*10+c-48;c=getchar();}
    return s*f;
}
void write(int x){
    if(x<0) {putchar('-');x=-x;}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
int n,a[maxn],cnt[2][maxn],mx1,mx11,mx2,mx22,n1,n2;
int main(int argc, char const *argv[])
{

    n=read();
    fors(i,1,n) {
        a[i]=read();
        ++cnt[i%2][a[i]];
    }
    fors(i, 1, maxn){
        if(cnt[0][i] > mx1){
            n1 = i;
            mx11 = mx1;
            mx1 = cnt[0][i];
        }
        else if(cnt[0][i] > mx11){
            mx11 = cnt[0][i];
        }
 
        if(cnt[1][i] > mx2){
            n2 = i;
            mx22 = mx2;
            mx2 = cnt[1][i];
        }
        else if(cnt[1][i] > mx22){
            mx22 = cnt[1][i];
        }
    }
    if(n1 == n2){
        int mx = max(mx1 + mx22, mx2 + mx11);
        write(n - mx);
    }
    else write(n/2-mx1 + n/2-mx2);
    return 0;
}

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

int main() {
  char b;
  cin >> b;
  if (b == 'A')
    cout << 'T';
  else if (b == 'T')
    cout << 'A';
  else if (b == 'G')
    cout << 'C';
  else if (b == 'C')
    cout << 'G';
  return 0;
}

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

void Main() {
    int n;
    cin >> n;
    int H[n];
    rep(i, 0, n) { cin >> H[i]; }
    int max = -INF, cnt, ans;
    rep(i, 1, n) {
        if (H[i - 1] >= H[i]) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt > max) {
            max = cnt;
            ans = cnt;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 640
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int INF = 1e9 + 5;

int k, n;
ll a[N], ans;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	for(int i = k + 1; i <= n; ++i) {
		ans += a[i];
	}
	cout << ans;
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = (w * h) / 2.0;
    int f = 0;
    if (2 * y == h && 2 * x == w)
        f = 1;
    else if (2 * y == h || 2 * x == w)
        f = 0;
    cout << ans << " " << f << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m;
long long ans[N*2];
int main(){
	scanf("%d%d",&n,&m);
	long long add=0;
	for(int i=1,last,now;i<=n;i++){
		scanf("%d",&now);
		if(now<last) now+=m;
		if(i!=1&&now!=last){
			add+=now-last;
			ans[now+1]+=1;
			ans[last+2]+=-1;
			ans[now+1]+=now-last-1;
			ans[now+2]+=last-now+1;
		}
		last=(now-1)%m+1;
	}
	for(int i=1;i<=m*2;i++) ans[i]+=ans[i-1];
	for(int i=1;i<=m*2;i++) ans[i]+=ans[i-1];
	long long out=1e18;
	for(int i=1;i<=m;i++) out=min(out,ans[i]+ans[i+m]+add);
	cout<<out<<endl;
	return 0;
} 

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

int main() {
  int N,M;
  cin>>N>>M;
  if(N==M){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c,d,e;
	scanf("%d %d %d",&a,&b,&c);
	if (a==1&&b==1&&c==0||a==0&&b==0&&c==1){
	printf("Open\n");
	}
	else {
        printf("Close\n");
	}	
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

int dfs(int W, vector< vector< pair<int, int> > > stuff, int w, int k) {
    if (W < w+k) {
        return 0;
    } else {
        int ret = 0;
        while (k<4) {
            if (W-(w+k) < 0) {
                break;
            }
            if (stuff[k].empty()) {
                k++;
                continue;
            }
            pair<int, int> tmp = stuff[k].back();
            stuff[k].pop_back();
            ret = max(ret, tmp.second + dfs(W-(w+k), stuff, w, k));
            stuff[k].push_back(tmp);
            k++;
        }
        return ret;
    }
}

void solve(int N, int W, vector< pair<int, int> > stuff) {
    int w = stuff[0].first;
    vector< vector< pair<int, int> > > stuff_wight_concern(4);
    for (int i = 0; i < N; i++) {
        stuff_wight_concern[stuff[i].first-w].push_back(stuff[i]);
    }
    for (int i = 0; i < 4; i++) {
        sort(stuff_wight_concern[i].begin(), stuff_wight_concern[i].end());
    }
    int ret = dfs(W, stuff_wight_concern, w, 0);
    std::cout << ret << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int N, W;

    gettimeofday(&start,NULL);

    std::cin >> N >> W;
    vector< pair<int, int> > stuff(N);
    for (int i = 0; i < N; i++) {
        std::cin >> stuff[i].first >> stuff[i].second;
    }
    solve(N, W, stuff);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 384
/*
 * Author: Utkal Sinha
 * Created on: 2020-09-19, Sat, 17:48
 * Problem:
 * Platfrom: General
 * */
#if USE_BOOST2
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; //int512_t or //int128_t
typedef bst::cpp_bin_float_100 vdouble;
#endif

#include <bits/stdc++.h>
using namespace std;
#define GETTIME std::chrono::system_clock::now()
#define DURATION std::chrono::duration<double>
#ifdef MY_DEV_ENV2
#define LOCALDEV
#endif
typedef long long ll;
typedef std::chrono::system_clock::time_point TPT;
static TPT starttime, endtime, timelimit;
static double problem_tle = 1.5;
static inline void calc_problem_end_time() {timelimit = starttime + std::chrono::milliseconds(int (problem_tle * 1000));}
// template end



void love() {
    string s;
    cin >> s;
    if(s.back() == 's') s += "es";
    else s += "s";
    cout << s << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    srand(time(0));
#ifdef LOCALDEV
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
#ifdef LOCALDEV
    starttime = GETTIME;
    calc_problem_end_time();
#endif
    while(t--) love();
#ifdef LOCALDEV
    endtime = GETTIME;
    DURATION elapsed_seconds = endtime - starttime;
    DURATION time_limit_seconds = timelimit - starttime;
    clog << "Elapsed time: " << elapsed_seconds.count() << "s\n";
    clog << "Time limit: " << time_limit_seconds.count() << "s\n";
#endif
    return 0;
}

Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v) for(int i=0; i<v.size(); i++)cout<<v[i]<<" "; cout<<endl;



#define LLU long long unsigned

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx <= vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() < xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] >= xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}





signed main() {
	int a, b, c, d,k;
	cin >> a >> b >> c >> d >> k;
	cout << max((c - a) * 60 + (d - b) - k,0ll) << endl;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  for (int b=0; b<=31; b++) {
    ll t = 0;
    for (int i=0; i<n; i++) {
      t += (a[i]>>b)&1;
    }
    if (t%2) {
      for (int i=0; i<n; i++) {
        a[i] = a[i]^(1<<b);
      }
    }
  }
  rep(i, n) {
    if (i>0) cout << " ";
    cout << a[i];
  }
  cout << endl;

  return 0;
}


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

int main(){
string a, b; cin >> a >> b;
int x = stoi(a + b);

for (int c = 1; c <= (x + 1)/2; c++) {
    if (c*c == x) {
        cout << "Yes" << endl;
        return 0;
    }
}

cout << "No" << endl;

}



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


int main()
{
	long long x, y;

    // 読み取り
    cin >> x >> y;

    if(abs(x - y) <= 1){
        cout << "Brown" <<endl;  
    }else{
        cout << "Alice" <<endl;  
    }

	return 0;
}

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

int main(){
  int n;
  int c = 0;
  cin >> n;
  int x = 1;
  int y = 1;
  for (int i=0; i<9; i++){
    for(int j=0; j<9; j++){
      if(x*y==n){c = 1;}
      x++;

    }
    x = 1;
    y++;
  }
  if(c==1){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
p_s = [list(map(str, input().split())) for _ in range(m)]

ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]

for i in range(m):
    if p_s[i][1] == 'WA':
        if ac[int(p_s[i][0]) - 1] == 0:
            wa[int(p_s[i][0]) - 1] += 1
    else:
        ac[int(p_s[i][0]) - 1] = 1

for i in range(n):
    if ac[i] == 0:
        wa[i]=0

print(sum(ac), sum(wa))


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

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

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int N;
  cin >> N;
  int F[100][10];
  REP(i,N)REP(j,10)cin >> F[i][j];

  int P[100][11];
  REP(i,N)REP(j,11)cin >> P[i][j];

  int ans = -(1<<30);
  FOR(i,1,1024){
    int t = i;
    int tmp = 0;
    // j: お店
    REP(j,N){
      int cnt=0;
      // k: 時間帯
      REP(k,10)
      if((i>>k) & 1){
        if(F[j][k])cnt++;
      }
      tmp += P[j][cnt]; 
    }
    ans = max(ans,tmp);
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
from copy import deepcopy
N=list(input())
lenn=len(N)-1
cnt=0
for i in range(2**lenn):
    n=deepcopy(N)
    b=(("0"*lenn)+bin(i)[2:])[-lenn:]
    for i in range(lenn-1,-1,-1):
        if b[i]=="1":
            n.insert(i+1,"+")
    cnt+=eval("".join(n))
print(cnt)

Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
  int a,b,c,d,e,f;
  double x,y;
  while(cin>>a>>b>>c>>d>>e>>f){
    y = (double)(a*f-d*c) / (a*e - b*d);
    x = (c-b*y) / a;
    cout << setprecision(3) << setiosflags(ios::fixed) << x << ' ' << setprecision(3) << setiosflags(ios::fixed) << y << endl;
  }
  return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const ll dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(ll y, ll x, ll H, ll W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

char G[55][55];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w; cin>>h>>w;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  rep(i,h){
    rep(j,w){
      if(G[i][j]=='#'){
        cout<<'#';
        continue;
      }
      ll cnt=0;
      rep(k,8){
        ll ny=i+dy[k], nx=j+dx[k];
        if(inside(ny,nx,h,w)&&G[ny][nx]=='#') cnt++;
      }
      cout<<cnt;
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <memory.h>
#include <iostream>

using namespace std;
#define MAX_SIZE 1000000000

int main()
{
	int n, x;
	char tmp;
	
	char *m = (char*)malloc(MAX_SIZE);
	if(m==0) {
		cout<<"error"<<endl;
	}
	memset(m, 0, MAX_SIZE);
	
	cin>>n;

	for(int i=0; i<n ; i++) {
		cin>>x;
		tmp = ++*(m+x);
		if(tmp>1) {
			cout<<"NO"<<endl;
			return 0;
		}
	}
	
	cout<<"YES"<<endl;
	
	return 0;
}


Measured memory_bytes: 976128
import math

a,b,h,m = tuple([int(x) for x in input().split(' ')])
m_kakudo = 2 * math.pi * (m / 60)
h_kakudo = 2 * math.pi * (h / 12) + m_kakudo / 12
kakudo = abs(m_kakudo-h_kakudo)
if kakudo >= (math.pi):
    kakudo = math.pi - (kakudo - math.pi)
ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(kakudo))
print(ans)


Measured memory_bytes: 62528
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll lastMax[3] = { 0 };

	FOR(i, 0, n) {
		ll thisBest[3] = { 0 };

		FOR(j, 0, 3) {
			ll curr = 0;
			//cin >> thisBest;

			FOR(z, 0, 3) {
				if(j != z) {
					curr = max(curr, lastMax[z]);					
				}
			}

			cin >> thisBest[j];
			thisBest[j] += curr;
		}

		FOR(j, 0, 3) {
			lastMax[j] = thisBest[j];
		}
	}

	ll maxi = 0;
	FOR(i, 0, 3) {
		//cout << maxi << endl;
		maxi = max(maxi, lastMax[i]);
	}

	cout << maxi << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int n;
vector<int> G[100010];
int dp[100010];
int s[100010];
void dfs(int v,int p){
	s[v] = 0;
	dp[v] = 0;
	for(int u: G[v]){
		if(p == u)continue;
		dfs(u,v);
		int t = s[v]&s[u];
		rep(i,20){
			if((t>>i)&1){
				dp[v] = max( dp[v] , i+1 );
			}
		}
		s[v] |= s[u];
	}
	while((s[v]>>dp[v])&1){
		s[v] -= 1<<dp[v];
		dp[v] ++;
	}
	s[v] &= (-1)^((1<<dp[v])-1);
	s[v] += 1<<dp[v];
	//cout << v << " " << dp[v] << " " << s[v] << endl;
}

int main(){
	int n;
	int a[100010],b[100010];
	scanf("%d",&n);
	rep1(i,n-1){
		scanf("%d%d",&a[i],&b[i]);
		G[a[i]].pb(b[i]);
		G[b[i]].pb(a[i]);
	}
	if(n <= 2){
		cout << n-1 << endl;
		return 0;
	}
	int root = 1;
	rep1(i,n){
		if(G[i].size() >= 2){
			root = i;
			break;
		}
	}
	dfs(root,0);
	
	int ret = 0;
	rep1(i,n)ret = max( ret , dp[i] );
	cout << ret << endl;
}


Measured memory_bytes: 11904
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 入力を取得
    int price = sc.nextInt();
    int coin = sc.nextInt();
    int maxTimes = sc.nextInt();

    int count = coin/price;
    if(count>maxTimes){
      count = maxTimes;
    }

    // 出力
    System.out.println(count);
  }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 
#define pb push_back
#define sz(a) (int)a.size()

void solve(){
	int n;
	cin >> n;
	vector<vi> tasks(n,vi(3));
	for(int i=0;i<n;++i){
		for(int j=0;j<3;++j){
		cin >> tasks[i][j];
		}
	}
	vector<vi> max_day_happiness(n,vi(3));
	max_day_happiness[0]=tasks[0];
	for(int i=1;i<n;++i){
		for(int j=0;j<3;++j){
			int now=0;
			for(int k=0;k<3;++k){
				if(j!=k) now=max(now,max_day_happiness[i-1][k]);
			}
			max_day_happiness[i][j]=tasks[i][j]+now;
		}
	}
	int ans=0;
	for(int i=0;i<3;++i){
		ans=max(ans,max_day_happiness[n-1][i]);
	}
	cout << ans << nl;
}
	

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

	solve();
	
	return 0;
}

Measured memory_bytes: 14292
#include<iostream>

using namespace std;

int main()
{
  int xel[100]={0}, x, y, buf;
  cin >> y >> x;
  for(int i=0; i<y; i++){
    int in;
    buf=0;
    for(int j=0; j<x; j++){
      cin >> in;
      buf+=in;
      xel[j]+=in;
      cout << in << ' ';
    }
    cout << buf << endl;
  }
  buf=0;
  for(int i=0; i<x; i++){
    buf+=xel[i];
    cout << xel[i] << ' ';
  }
  cout << buf << endl;
  return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
#include<iostream>
#include<math.h>
int main(){
    long long  n,a,b,c,d,e;
    scanf("%lld" , &n);
    scanf("%lld" , &a);
    scanf("%lld" , &b);
    scanf("%lld" , &c);
    scanf("%lld" , &d);
    scanf("%lld" , &e);
    long long h[] = {a,b,c,d,e};
    long long  min = pow(10 , 15);
    for(int t=0;t<5;t++){
        if(h[t] < min)min = h[t];
    }
    long long m;
    if(n<min){
        m = 5;
    }else{
        if(n%min==0){
            m = n/min + 4;
        }else{
            m = (n/min) + 5;
        }

    }
    printf("%lld\n" , m);
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define nl cout<<'\n'
#define nll <<'\n'
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL)
int main()
{
    int a;
    cin>>a;
    double r=(double)a/3;
    double ans=r*r*r;
    printf("%.9lf",ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int n;
typedef pair<int, int> P;
vector<P> vec;

// dp[i][j]: length from i to j
vector<vector<double>> dp;

int main() {
  cin >> n;
  vec.assign(n, P(0, 0));
  dp.assign(n, vector<double>(n));
  rep(i, n) { cin >> vec[i].first >> vec[i].second; }
  rep(i, n) {
    rep(j, n) {
      dp[i][j] = sqrt(pow(vec[i].first - vec[j].first, 2) +
                      pow(vec[i].second - vec[j].second, 2));
    }
  }

  double sum = 0;
  vector<int> order(n);
  rep(i, n) { order[i] = i; }

  int pattern = 0;
  do {
    rep(i, n - 1) {
      int from = order[i];
      int to = order[i + 1];
      sum += dp[from][to];
    }
    pattern++;

  } while (next_permutation(order.begin(), order.end()));
  double avg = sum / pattern;
  printf("%.10f", avg);
}


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
    st,IN=map(str,input().split())
    a.append([st,IN])
a=a[::-1]
x=input()
ss=0
for y in a:
    if y[0]==x:
        break
    ss+=int(y[1])
print(ss)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vvectorl vector<vector<long long>>
#define vectorl vector<long long>
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int squ(int x) {
	return x * x;
}
int di(vectorl x, vectorl y, int i, int j) {
	return squ(x[i] - x[j]) + squ(y[i] - y[j]);
}
int qmmin(int &a, int b) {
	if (a == -1) {
		a = b;
	}
	else {
		a = min(a, b);
	}
	return a;
}
int nex(int a) {
	return (a + 1) % 3;
}
signed main() {
	int n, sw;
	cin >> n >> sw;
	vector<int> sv(sw + 1,0);
	vector<int> qsv;
	for (int i = 0; i < n; i++) {
		qsv = sv;
		int w, v;
		cin >> w >> v;
		for (int j = 0; j + w <= sw; j++) {
			sv[j + w] = max(sv[j + w], qsv[j] + v);
		}
	}
	int ans = 0;
	for (int i = 0; i <= sw; i++) {
		ans = max(ans, sv[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
# include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>  
# define  lcm(a, b)     (a * b) / __gcd(a, b)  
	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     												using namespace std;
const long INF = 1e18;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
void solve(){
	long n, res = 1;
	cin >> n;
	long ar[n];
	for(auto &i: ar) cin >> i;
	sort(ar, ar + n);
	for (int i = 0; i < n; ++i){
		if( ar[i] == 0){ cout << 0; return; }
		if( res > INF / ar[i] ){ cout << -1; return;}
		res *= ar[i];
	}
	cout << res;
} 
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        cout << fixed << setprecision(9);
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
} 													


Measured memory_bytes: 4596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String matrix[][] = new String[2][n];

		for (int i = 0; i < 2; i++) {
			String str[] = br.readLine().split("");
			for (int j = 0; j < n; j++) {
				matrix[i][j] = str[j];
			}
		}

		int prev = -1;
		long ans = 1;

		for (int i = 0; i < n; i++) {
			if (matrix[0][i].equals(matrix[1][i])) {
				if (prev == 1) {
					ans *= 2;
				} else if (prev == 2) {
					ans *= 1;
				} else {
					ans *= 3;
				}
				prev = 1;
			} else {
				if (prev == 1) {
					ans *= 2;
				} else if (prev == 2) {
					ans *= 3;
				} else {
					ans *= 6;
				}
				prev = 2;
				i++;
			}
			ans %= 1000000007;
		}
		System.out.println(ans % 1000000007);
	}
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0)
#define MAXX 1005

int a , b , c;

int main()
{
    _FastIO;
    cin >> a >> b >> c;
    if(a > b)   swap(a , b);
    if(c < a || c > b){
        cout << "No" << endl;
    }
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3632
def make2d(m,n)
  Array.new(m).map{Array.new(n,0)}
end


def min(x,y)
  if x > y
    return y
  else
    return x
  end
end

def align_ed(s,t)
  m = s.length()
  n = t.length()
  a = make2d(m+1,n+1)
  a[0][0] = 0
  for j in 1..n
    a[0][j] = a[0][j-1] + 1
  end
  for i in 1..m
    a[i][0] = a[i-1][0] + 1
  end
  for i in 1..m 
    for j in 1..n
      x = a[i-1][j-1]
      if s[i-1] != t[j-1]
        x += 1
      end
      y = a[i][j-1] + 1                         
      z = a[i-1][j] + 1
      a[i][j] = min(x,min(y,z))
    end
  end
  a[-1][-1]
end


s1 = gets.chomp
s2 = gets.chomp
puts align_ed(s1,s2)

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int n, a, ans;

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a);
    if(i){
      if(ans < a) swap(ans, a);
      while(a){
        ans %= a;
        swap(a, ans);
      }
    }else ans = a;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int sum;
		while(sc.hasNext()){
			sum=0;
			for(int i=0;i<4;i++){
				sum+=sc.nextInt();
			}
			System.out.println(sum/60);
			sum%=60;
			System.out.println(sum);
		}

	}

}

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

int main(){
  int N,M;
  cin >> N;
  M = 0;
  vector<int> weight(N);
  for(int i = 0;i<N;i++){
    cin >> weight.at(i);
  }
  for(int i=0;i<N;i++){
    M += weight.at(i);
  }
  vector<int> S1(N),S(N);
  for(int i=0;i<N;i++){
    for(int j=0;j<i+1;j++){
      S1.at(i) += weight.at(j);
    }
    S.at(i) = fabs(M-2*S1.at(i));
  }
  sort(S.begin(),S.end());
  cout << S.at(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define rforn(a, n) for(int a = (n)-1; a>=0; --a)
using namespace std;
const int N = 6e5+20;

int main()
{
    int n, m, b;
    cin>>n;
    m = n;
    b=0;
    while(m>=15)
    {
        m-=15;
        b++;
    }
    cout<<n*800-(200*b)<<endl;

}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main(){
int a,b,c[100000],d,e;
cin>>a>>b;
  d=0;
  e=1;
for(int i=0;i<a;i++){
    cin>>c[i];
  d+=c[i];
  if(d<=b){e++;}
  
}
  cout<<e;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string;
 
void main()
{
    auto s = readln.chomp;
    auto cnt = 0;
    char last = s[0];
    foreach (c; s[1..$]) {
        if (c != last) {
            ++cnt;
            last = c;
        }
    }
    writeln(cnt);
}

Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second

char col[4] = { 'R', 'G', 'B', 'Y', };

char sol(int x,int y,int d){
	if(d&1){
		return col[(x^y)&1];
	}
	if((x^y)&1)return sol(x+1,y,d);
	int s = x+y;
	int t = x-y;
	while(t < 0)t += 2*d;
	s %= 2*d;
	t %= 2*d;
	return col[((s<d)?0:2)+((t<d)?0:1)];
}

int main(){
	int H,W,d;
	scanf("%d%d%d",&H,&W,&d);
	
	for(int i = 0 ; i < H ; i ++){
		for(int j = 0 ; j < W ; j ++){
			printf("%c",sol(i,j,d));
		}
		printf("\n");
	}
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    string S;
    cin >> S;
    if (S == "#"){
      break;
    }
    vector<int> c(128);
    for (int i = 0; i < 128; i++){
      c[i] = S[i] - '0';
    }
    bool ok = true;
    for (int i = 0; i < (1 << 19); i++){
      /*
      -- -- 00 -- --
      -- 01 -- 02 --
      03 -- 04 -- 05
      -- 06 -- 07 --
      08 -- 09 -- 10
      -- 11 -- 12 --
      13 -- 14 -- 15
      -- 16 -- 17 --
      -- -- 18 -- --
      */
      int b0 = c[((i >> 18 & 1) << 0) + ((i >> 17 & 1) << 1) + ((i >> 16 & 1) << 2) + ((i >> 14 & 1) << 3) + ((i >> 12 & 1) << 4) + ((i >> 11 & 1) << 5) + ((i >> 9 & 1) << 6)];
      int b1 = c[((i >> 17 & 1) << 0) + ((i >> 15 & 1) << 1) + ((i >> 14 & 1) << 2) + ((i >> 12 & 1) << 3) + ((i >> 10 & 1) << 4) + ((i >> 9 & 1) << 5) + ((i >> 7 & 1) << 6)];
      int b2 = c[((i >> 16 & 1) << 0) + ((i >> 14 & 1) << 1) + ((i >> 13 & 1) << 2) + ((i >> 11 & 1) << 3) + ((i >> 9 & 1) << 4) + ((i >> 8 & 1) << 5) + ((i >> 6 & 1) << 6)];
      int b3 = c[((i >> 14 & 1) << 0) + ((i >> 12 & 1) << 1) + ((i >> 11 & 1) << 2) + ((i >> 9 & 1) << 3) + ((i >> 7 & 1) << 4) + ((i >> 6 & 1) << 5) + ((i >> 4 & 1) << 6)];
      int b4 = c[((i >> 12 & 1) << 0) + ((i >> 10 & 1) << 1) + ((i >> 9 & 1) << 2) + ((i >> 7 & 1) << 3) + ((i >> 5 & 1) << 4) + ((i >> 4 & 1) << 5) + ((i >> 2 & 1) << 6)];
      int b5 = c[((i >> 11 & 1) << 0) + ((i >> 9 & 1) << 1) + ((i >> 8 & 1) << 2) + ((i >> 6 & 1) << 3) + ((i >> 4 & 1) << 4) + ((i >> 3 & 1) << 5) + ((i >> 1 & 1) << 6)];
      int b6 = c[((i >> 9 & 1) << 0) + ((i >> 7 & 1) << 1) + ((i >> 6 & 1) << 2) + ((i >> 4 & 1) << 3) + ((i >> 2 & 1) << 4) + ((i >> 1 & 1) << 5) + ((i >> 0 & 1) << 6)];
      int b7 = c[(b0 << 0) + (b1 << 1) + (b2 << 2) + (b3 << 3) + (b4 << 4) + (b5 << 5) + (b6 << 6)];
      if (b3 != b7){
        ok = false;
        break;
      }
    }
    if (ok){
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}


Measured memory_bytes: 3152
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
LL a[1010];
LL q[1000005];

int main(){
    INIT;
    cin >> n >> k;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        a[i] += a[i - 1];
    }
    int idx = 0;
    for(int i = 1; i <= n;i++){
        for(int j = i;j <= n;j++){
            q[idx] = a[j] - a[i - 1];
            idx++;
        }
    }
    LL ans = 0;
    for(LL i = 40; i >= 0;i--){
        ans += (1LL << i);
        int cnt = 0;
        REP(j, idx)if((q[j]&ans) == ans)cnt++;
        if(cnt < k)ans -= (1LL << i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4352
n = int(input())
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
    tmp = list(map(int, input().split()))
    a[i] = tmp[0]
    b[i] = tmp[1]
    c[i] = tmp[2]

# dp[i][j]: i+1日目 j を遊んだときの幸福度の総和の最大値
dp = [[0] * 3 for i in range(n)]

dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i])
    dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i])
    dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i])

print(max(dp[-1]))


Measured memory_bytes: 61656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main() {
    ll N, M, a, b;
    cin >> N >> M;
    vector<pair<ll,ll>> vec(M);
    FOR(i,0,M-1) {
        cin >> a >> b; --a, --b;
        vec[i].first = a;
        vec[i].second = b;
    }

    // calculation
    UnionFind uf(N);
    ll res = 0;
    FOR(i,0,M-1) {
        uf.init(N);
        FOR(j,0,M-1) {
            if (j == i) continue;
            uf.merge(vec[j].first, vec[j].second);
        }
        if (uf.size(0) != N) res++;
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 1010
#define LL long long
using namespace std;

const LL P=1000000007;

int n,m;
LL k;
int a[MAXN][MAXN];
LL c1,c2,c3;

struct Mat{
	struct Data{
		LL a[2][2];
	}*data;

	void alloc(){
		data=new Data; 
		memset(data->a,0,sizeof data->a);
	}

	void free(){ delete data; }

	LL& operator()(int i,int j){ return data->a[i][j]; }

	Mat clone(){
		Mat res;
		res.alloc();
		for(int i=0;i<2;i++) for(int j=0;j<2;j++) res(i,j)=data->a[i][j];
		return res;
	}
};

void mul(Mat x,Mat y){
	static LL temp[2][2];
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
			temp[i][j]=(x(i,0)*y(0,j)+x(i,1)*y(1,j))%P;
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
			x(i,j)=temp[i][j];
}

Mat getPow(Mat x,LL y){
	Mat res;
	res.alloc();
	x=x.clone();
	for(int i=0;i<2;i++) res(i,i)=1;
	while(y){
		if(y&1) mul(res,x);
		mul(x,x);
		y>>=1;
	}
	x.free();
	return res;
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%d%d%lld",&n,&m,&k);
	if(!k){
		puts("1");
		return 0;
	}
	for(int i=1;i<=n;i++){
		static char str[MAXN];
		scanf("%s",str+1);
		for(int j=1;j<=m;j++)
			if(str[j]=='#') a[i][j]=1;
	}
	bool flag1=0,flag2=0;
	for(int i=1;i<=m;i++) if(a[1][i] && a[n][i]) flag1=1;
	for(int i=1;i<=n;i++) if(a[i][1] && a[i][m]) flag2=1;
	if(flag1 && flag2){
		puts("1");
		return 0;
	}
	if(flag1){
		swap(flag1,flag2);
		swap(n,m);
		for(int i=0;i<MAXN;i++)
			for(int j=0;j<i;j++)
				swap(a[i][j],a[j][i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]) c1++;
			if(a[i][j] && a[i][j+1]) c2++;
		}
		if(a[i][1] && a[i][m]) c3++;
	}
	Mat trans;
	trans.alloc();
	trans(0,0)=c1;
	trans(1,1)=c3;
	trans(1,0)=-c2;
	trans=getPow(trans,k-1);
	LL ans=trans(0,0)+(flag2?trans(1,0):0);
	ans=(ans%P+P)%P;
	printf("%lld\n",ans);
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  int h,w; cin>>h>>w;
  vector<string> a(h);
  rep(i,h) cin>>a[i];
  vector<int> x(w, 0);
  vector<int> y(h, 0);
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (a[i][j]=='#') {
        x[j]=1;
        y[i]=1;
      }
    }
  }
  for (int i=0; i<h; i++) {
    if (y[i]==0)continue;
    for (int j=0; j<w; j++) {
      if (x[j]==0)continue;
      cout<<a[i][j];
    }
    cout<<endl;
  }
}

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


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

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

  // ここにプログラムを追記
  string s="";
  int four=0,i=0;
  for (int i=0; i<N; i++) {
    cin >> s;
  	if (s=="Y") {
      four = 1;
    }
  }
  if (four==1) {
    cout << "Four" <<endl;
  } else {
 	cout << "Three" <<endl;
  }
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

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

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

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



	public void exec() throws Exception{
		final int N = sc.nextInt();
		final int R = sc.nextInt();
		if(N >= 10) {
			out.println(R);
		}else {
			out.println(R + 100*(10 - N ));
		}
	}
}


Measured memory_bytes: 22868