akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;


void weather_predicition()
{
  string s;
  cin >> s;

  if (s == "Sunny") cout << "Cloudy\n";
  else if (s == "Cloudy") cout << "Rainy\n";
  else if (s == "Rainy") cout << "Sunny\n";
}


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

  int cnt = 0;
  for (int i = 1; i <= n; ++i)
  {
    if (i % 2 != 0) ++cnt;
  }

  cout << (float)cnt / (float)n << "\n";
}


void curtain()
{
  int a, b;
  cin >> a >> b;

  if (a - 2 * b > 0) cout << a - 2 * b << "\n";
  else cout << 0 << "\n";
}


void cant_wait_for_holiday()
{
  string s;
  cin >> s;

  vector<string> S{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  int cnt = 7;
  for (int i = 0; i < 7; ++i)
  {
    if (s == S[i]) cout << cnt << "\n"; 
    --cnt;
  }

}


void blackjack()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

  if (accumulate(a.begin(), a.end(), 0) >= 22) cout << "bust\n";
  else cout << "win\n";
}


void round_one()
{
  int a, b;
  cin >> a >> b;

  cout << 6 - a - b;
}


void strings()
{
  string s, t;
  cin >> s >> t;

  cout << t + s << "\n";
}


int main()
{
  //weather_predicition();
  //odds_of_oddness();
  //curtain();
  //cant_wait_for_holiday();
  //blackjack();
  //round_one();
  strings();
}

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

cum_sum = [0]
acc = 0
for i in lst:
  acc += i
  cum_sum.append(acc)

dic = {}
for i in cum_sum:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1

ans = 0


for i in dic:
  v = dic[i]
  if v >= 2:
    ans += (v * (v - 1)) // 2
print(ans)


Measured memory_bytes: 114028
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    bool flag = true;
    REP(i, 3){
        if(S[i] == S[i+1]){
            flag = false;
        }
    }

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

Measured memory_bytes: 3584
# How many ways?

import math

end = 0
while end == 0:
    a = [int(i) for i in input().rstrip().split()]
    n = a[0]
    x = a[1]
    if n == 0 and x == 0:
        end += 1
    else:        
        if x <= 5 or x >= 298 or 3 * (n - 1) < x:
            ways = 0
            print(ways)
        elif x <= 7:
            ways = 1 # x = 6 のとき (1, 2, 3), x = 7 のとき (1, 2, 4)
            print(ways)
        else: # x >= 8 のとき
            ways = 0 # Initialize
            maximumLow = x // 3 - 1 # 選ぶ数の最小値の最大
            minimumHigh = math.ceil(x / 3) + 1 # 選ぶ数の最大値の最小
            # 最小値を選ぶ
            for i in range(1, maximumLow + 1):
                topTwo = x - i
                minimumMid = i + 1
                maximumMid = topTwo // 2
                minimumHigh = topTwo // 2 + 1
                # 中間値を選ぶ
                for j in range(minimumMid, maximumMid + 1):
                    wantedHigh = x - i - j
                    if minimumHigh <= wantedHigh <= n:
                        ways += 1
            print(ways)



Measured memory_bytes: 5672
import java.util.Scanner;
public class Main{
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); 
		int ans[]=new int[n];
		int point[][] = new int[n][3];
		for(int i=0;i<n;i++){
			for(int j=0;j<3;j++){
				point[i][j] = sc.nextInt();
			}
		}
		
		
		int cnt=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<3;j++){
				for(int k=0;k<n;k++){
					//System.out.println(point[i][j]+" "+point[k][j]);
					if(point[i][j] == point[k][j])cnt++;
				}
				if(cnt==1)ans[i]+=point[i][j];
				cnt=0;
			}
			System.out.println(ans[i]);
		}
		
		
	}
}

Measured memory_bytes: 20812
A = 0
B = 1
C = 2

table = {"A": A, "B": B, "C": C}

s = [table[c] for c in input()]
s.reverse()

total = 0
bc_count = 0
prev = None
for c in s:
	if c == A:
		if prev == C:
			bc_count = 0
		else:
			total += bc_count
	elif c == B:
		if prev == C:
			bc_count += 1
		else:
			bc_count = 0
	elif c == C:
		if prev == C:
			bc_count = 0
	prev = c

print(total)


Measured memory_bytes: 5096
#include<bits/stdc++.h>
#define EPS (1e-8)
using namespace std;
typedef complex<double> point;

vector<point> CrossPoints_CC(point a,double ra,point b,double rb){
  vector<point> res;
  b-=a;
  double d= ( norm(b) + ra*ra - rb*rb ) / ( 2.0 * abs(b)  );
  double  c = sqrt( ra*ra - d*d );

  point base = b/abs(b);
  res.push_back(point(d,c) * base + a);
  res.push_back(point(d,-c) * base + a);  
  return res;
}


int main(){
  point c1,c2;
  double a,b,r1,r2;
  cin>>a>>b>>r1;
  c1=point(a,b);
  cin>>a>>b>>r2;
  c2=point(a,b);
  vector<point> ans=CrossPoints_CC(c1,r1,c2,r2);
  if(ans[0].real()>ans[1].real())swap(ans[0],ans[1]);
  if(ans[0].real()==ans[1].real())
    if(ans[0].imag()>ans[1].imag())swap(ans[0],ans[1]);
  for(int i=0;i<2;i++){
    if(i)cout<<' ';
    printf("%.8f %.8f",ans[i].real(),ans[i].imag());
  }
  cout<<endl;
  return 0;
}

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

#define N 100000
#define INF 1000000

typedef struct{
  int g; //go 前に進む
  int b; //back 後ろに戻る
  int c; //cost コスト
}Date;

int n, d[N];
Date a[500000];

void root(int);

int main(){
  int i, j;
  int k, u, count = 0;

  scanf("%d",&n);
for(i=0;i<n;i++)
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      a[count].b = u;
      scanf("%d%d",&a[count].g,&a[count].c);
      count++;
    }
  }

  root(count);

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

  return 0;
}

void root(int x){
  int i, flag = 1;

  for(i = 0 ; i < n ; i++) d[i] = INF;
  d[0] = 0;

  while(flag != 0){
    flag = 0;
    for(i = 0 ; i < x ; i++){
      if(a[i].c + d[a[i].b] < d[a[i].g]){
	d[a[i].g] = a[i].c + d[a[i].b];
	flag = 1;
      }
    }
  }
}



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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

signed main(){
    io();
    int n; cin >> n;
    string s; cin >> s;
    for(int i = 0; i < (int)s.size(); ++i){
        if(s[i] + n > 'Z'){
            s[i] -= (26 - n);
        }else{
            s[i] += n;
        }
    }
    cout << s << '\n';
    return 0;
}

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

int check(int *x, int *y, int t) {
  int i;
  for (i = 0; i < t; i++) {
    if(x[i] == x[t]) return 1;
    if(y[i] == y[t]) return 1;
    if(x[i]+y[i] == x[t]+y[t]) return 1;
    if(x[i]-y[i] == x[t]-y[t]) return 1;
  }
  return 0;
}

void search(int *x, int *y, int *t) {
  while(*t < 8) {
    if(y[*t] == 7) {
      x[*t]++;
      y[*t] = 0;
    }
    else {
      y[*t]++;
    }
    if(x[*t] > 7) {
      x[*t] = 0;
      y[*t] = -1;
      (*t)--;
    }
    else if(check(x,y,*t) == 0) {
      (*t)++;
    }

  }
}

void print_board(int *x, int *y) {
  int i,j,t;
  for (i = 0; i < 8; i++) {
    for (t = 0; i != x[t]; t++);
    for (j = 0; j < 8; j++) {
      if(j == y[t]) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

int main()
{
  int i,t,k,*x,*y;
  x = (int*)malloc(sizeof(int) * 8);
  y = (int*)malloc(sizeof(int) * 8);
  for (i = 0; i < 8; i++) {
    x[i] = 0;
    y[i] = -1;
  }
  t = 0;
  scanf("%d",&k);
  for(i = 0; i < k; i++) {
    scanf("%d %d",x+i,y+i);
    t++;
  }

  search(x,y,&t);

  print_board(x,y);
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i,j,count=0;
	i=0;
	j=s.size()-1;
	while(i<j&&i<s.size()&&j>0)
	{
		if(s[i]!=s[j])
		{
			count++;
		}
		i++;
		j--;
	}
	cout<<count<<endl;
}

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

using ll = long long;

#define rep(i, n) for(int i = 0; i < (n); i++)

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(N); cin >> A;

    vector<ll> sum;
    ll all_or = 0;
    rep(i, N) {
        ll s = 0;
        for (int j = i; j < N; j++) {
            s += A[j];
            sum.push_back(s);
            all_or |= s;
        }
    }
    set<int> idx;
    for (int i = 0; i < sum.size(); i++) {
        idx.insert(i);
    }

    ll ans = 0;
    for (ll b = (1LL << 41); b > 0; b >>= 1) {
        if (!(all_or & b)) continue;
        set<int> on;
        for (int i : idx) {
            if (sum[i] & b) {
                on.insert(i);
            }
        }
        if (on.size() >= K) {
            ans |= b;
            idx = on;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 32880
from math import log
N = int(input())
dp = [0] * (10**5+1)
dpl = set()
a = 1
b = 1
while True:
    if a > 10**5:
        break
    a *= 6
    dpl.add(a)
while True:
    if b > 10**5:
        break
    b *= 9
    dpl.add(b)

for i in range(1, 10**5+1):
    if i < 6:
        dp[i] = i
        continue
    log6 = log(i, 6)
    log9 = log(i, 9)
    l = set(map(float, range(1, 20)))
    # 6の乗数、9の乗数の場合は1でdpを埋める
    if log6 in l:
        dp[i] = 1
    elif log9 in l:
        dp[i] = 1
    # それ以外の数値は各6, 9の乗数を引いた値から最も小さい数で埋める
    else:
        minl = [dp[i-d]+1 for d in dpl if i-d >= 0]
        if minl:
            dp[i] = min(minl)

print(dp[N])

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//


int H,W,A,B;

map<ii,ll> memo;

inline ll y(int dh, int dw){
    ii k = ii(dh+dw, dw);
    // fprintf(stderr, "k=(%d,%d)\n", dh+dw, dw);
    // assert(found(memo,k));
    return memo[k];
#if 0
    ll res = comb(dh+dw, dh);
#ifdef DEBUG
    fprintf(stderr, "  y(%d,%d) = %d C %d = %lld\n", dh,dw, dh+dw,dw, res);
#endif
    memo[k] = res;
    return res;
#endif
}

void prepare_comb(){
    ll last;
    for (int r=H-A+B-1,k=B; k<W; ++r,++k) {
        last = memo[ii(r,k)] = (k==B) ? comb(r,k) : DIV(MUL(last,r),k);
        // fprintf(stderr, ": %dC%d = %lld\n", r,k,last);
    }
    for (int r=A-1,k=0; k<W-B; ++r,++k) {
        last = memo[ii(r,k)] = (k==0) ? comb(r,k) : DIV(MUL(last,r),k);
        // fprintf(stderr, ": %dC%d = %lld\n", r,k,last);
    }
}

ll route(int s){
    // (0,0) - (H-A-1,s) - (H-A,s) - (H-1,W-1)
    // fprintf(stderr, "s=%d: (%d,%d)-(%d,%d)-(%d,%d)-(%d,%d)\n", s, 0,0, H-A-1,s, H-A,s, H-1,W-1);
    return MUL(y(H-A-1, s), y(A-1, W-1-s));
}

ll solve() { // ll H,ll W,ll A,ll B) {
    prepare_comb();
    // fprintf(stderr, "solve(H=%d,W=%d, A=%d,B=%d)\n", H,W,A,B);
    ll ans = 0LL;
    for (int s=B; s<W; ++s) {
        ans = ADD(ans, route(s));
    }
    return ans;
}

int main() {
    cin >> H >> W >> A >> B;
    cout << solve() << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  int A,B; cin >> A >>B ;
  cout << A*B << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here

string func(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	foreach(i,s){
		i-='A';
		i+=n;
		i%=26;
		i+='A';
	}
	return s;
}
int main(){
	cout << func() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 4e5 + 5;
const int MAX = 250000 + 5;
const int M = 3e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e18;
const int LG = 21;


int cnt[N];

void solve()
{
	int n;
	cin >> n;
	int ret = 0;
	for(int i = 1; i <= n; i++)
	{
		int data;
		cin >> data;
		ret += ((i & 1) and (data & 1));
	}
	cout << ret << endl;
}
 
int32_t main() 
{	

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

vector<int> evens, odds;
int N, M;
int main(){ 
    cin >> N >> M;
    while (M --) {
        int x;
        cin >> x;
        if (x % 2) {
            odds.push_back(x);
        } else {
            evens.push_back(x);
        }
    }
    if (odds.size() > 2) {
        cout << "Impossible\n";
        return 0;
    }
    if (odds.size() == 0) {
        for (int x : evens) cout << x << ' ';
        cout << '\n';

        cout << 1 + evens.size() + (evens.back() > 2) << '\n';
        cout << 1 << ' ';
        for (int i = 0; i < (int) evens.size() - 1; i ++) {
            cout << evens[i] << ' ';
        }
        cout << 1 << ' ';
        if (evens.back() > 2) cout << evens.back() - 2 << ' ';
        cout << '\n';
        return 0;
    }
    if (odds.size() == 1) {
        cout << odds[0] << ' ';
        for (int x : evens) cout << x << ' ';
        cout << '\n';

        if (evens.empty()) {
            cout << 1 + (odds[0] > 1) << '\n';
            cout << 1 << ' ';
            if (odds[0] > 1) cout << odds[0] - 1 << ' ';
            cout << '\n';
            return 0;
        }
        cout << 1 + evens.size() + (evens.back() > 2) << '\n';
        cout << odds[0] + 1 << ' ';
        for (int i = 0; i < (int) evens.size() - 1; i ++) {
            cout << evens[i] << ' ';
        }
        cout << 1 << ' ';
        if (evens.back() > 2) cout << evens.back() - 2 << ' ';
        cout << '\n';
        return 0;
    }
    if (odds.size() == 2) {
        cout << odds[0] << ' ';
        for (int x : evens) cout << x << ' ';
        cout << odds[1] << '\n'; 

        cout << 1 + evens.size() + (odds[1] > 1) << '\n';
        cout << odds[0] + 1 << ' ';
        for (int i = 0; i < (int) evens.size(); i ++) {
            cout << evens[i] << ' ';
        }
        if (odds[1] > 1) cout << odds[1] - 1 << '\n';
        return 0;
    }
    return 0;
}


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

using namespace std;

int main() {
	int N, Y;
	scanf("%d%d", &N, &Y);
	for(int i = 0; i <= Y / 10000; i++) {
		for(int j = 0; j <= Y / 5000; j++) {
			int k = N - i - j;
			if(k < 0) continue;
			if(i * 10000 + j * 5000 + k * 1000 == Y) {
				printf("%d %d %d\n", i, j, k);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int a[n];
  REP(i, n)cin>>a[i];

  if(n==1){
    cout<<1<<endl;
    return 0;
  }

  int l=0, r=1;
  LL ans=n;
  int work=a[0];
  for(int r=1; r<n; ++r){
    if((work&a[r])==0){
      work = (work|a[r]);
    }
    else{
      while((work&a[r])!=0 && l<r){
        work = (work &(~a[l]));
        ++l;
      }
      work = (work|a[r]);
    }
    ans = ans + r-l;
    //cout<<work<<" "<<l<<" "<<r<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
n=int(input())
from math import gcd
import itertools
lst=[i for i in range(1,n+1)]
kumi=list(itertools.combinations_with_replacement(lst,3))
ans=0
for i in range(len(kumi)):
    a=kumi[i][0]
    b=kumi[i][1]
    c=kumi[i][2]
    g=gcd(gcd(a,b),c)
    if a==b==c:
        ans+=g
    elif a==b or a==c or b==c:
        ans+=3*g
    else:
        ans+=6*g

print(ans)

Measured memory_bytes: 175848
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STR(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}

int main(){
	int N;
	int ans = 0;
	int l, r;
	scanf("%d", &N);
	REP(i, N){
		scanf("%d%d", &l, &r);
		ans += r - l + 1;
	}
	printf("%d\n", ans);
}

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

int main(void) {
  auto n = 0;
  cin >> n;

  auto ans = 0;
  for (auto i = 1; i <= n; i += 2) {
    auto num = 0;
    for (auto j = 1; j <= n; j += 2) {
      if (int(i % j) == 0) {
        num += 1;
      }
    }
    if (num == 8) {
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Set<String> set = new HashSet<>();
    
    int n = sc.nextInt();
    
    for (int i = 0; i < n; i++) {
      set.add(sc.next().trim());
    }
    
    System.out.println(set.size());
  }
}

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

int main() {
    int H, W, K, b=0;
    cin >> H >> W >> K;
    vector<vector<char>> c(6, vector<char>(6));

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> c.at(i).at(j);
        }
    }

    int ans = 0;

    for (int maskR = 0; maskR < (1<<H); maskR++)
    {
        for (int maskC = 0; maskC < (1<<W); maskC++)
        {
            int black = 0;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (((maskR>>i)&1) == 0 && ((maskC>>j)& 1)==0 && c[i][j] == '#') 
                    {
                        black++;
                    }
                    
                }
                
            }
            if (black == K){
                ans++;
            }
        }
        
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<int64_t, vector<int64_t>, greater<int64_t>> cont;
  
  for(int i = 0 ; i < n ; i++){
    int a;
    cin >> a;
    cont.push(a);
  }
  
  vector<pair<int64_t , int64_t>> aaa(m);
  
  for(int i = 0 ; i < m ; i++){
    cin >> aaa.at(i).second;
    cin >> aaa.at(i).first;
  }
  sort(aaa.begin() , aaa.end());
  reverse(aaa.begin() , aaa.end());
  
  bool jad = false;
  for(int i = 0 ; i < m ; i++){
    for(int j = 0 ; j < aaa.at(i).second ; j++){
      if(cont.top() < aaa.at(i).first){
        cont.push(aaa.at(i).first);
        cont.pop();
      }
      else{
        jad = true;
        break;
      }
    }
    if(jad){
      break;
    }
  }
  
  int64_t ans = 0;
  for(int i = 0 ; i < n ; i++){
    ans += cont.top();
    cont.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int H,W;cin>>H>>W;
    vector<vector<int>> S(H,vector<int>(W)),A(H,vector<int>(W,0)),B(H,vector<int>(W,0)),dp(H,vector<int>(W,0));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            //scanf("%d",&S[i][j]);
            cin>>S[i][j];
        }
    }
    
    for(int j=0;j<W;j++){
        if(!S[H-1][j]) A[H-1][j]=1;
        for(int i=H-2;i>=0;i--){
            if(!S[i][j]) A[i][j]=A[i+1][j]+1;
            else A[i][j]=0;
        }
    }
    
    for(int i=0;i<H;i++){
        if(!S[i][W-1]) B[i][W-1]=1;
        for(int j=W-2;j>=0;j--){
            if(!S[i][j]) B[i][j]=B[i][j+1]+1;
            else B[i][j]=0;
        }
    }
    
    for(int j=W-1;j>=0;j--){
        if(!S[H-1][j]) dp[H-1][j]=1;
    }
    
    for(int i=H-2;i>=0;i--){
        if(!S[i][W-1]) dp[i][W-1]=1;
        for(int j=W-2;j>=0;j--){
            int maxi=min(A[i][j],B[i][j]);
            if(maxi>dp[i+1][j+1]) dp[i][j]=dp[i+1][j+1]+1;
            else dp[i][j]=maxi;
        }
    }
    
    int ans=0;
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans=max(ans,dp[i][j]*dp[i][j]);
            //if(j) cout<<" ";
            //cout<<dp[i][j];
        }
        //cout<<endl;
    }
    
    cout<<ans<<endl;
    
    
}




Measured memory_bytes: 33748
#include <iostream>
#include <numeric>
	//#include <vector>
	//#include<math.h>
	//#include <algorithm>
	//#include <functional>
	//#include <numeric>
	//#include<cmath>
	//#include <stdio.h> 
	//#include <cstdint>
	//#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
using namespace std;
int main() {

		int a, b;
		cin >> a;
		cin >> b;

		if (a != 1 && b != 1) {
			cout << 1;
		}
		else if	(a != 2 && b != 2) {
			cout << 2;
		}
		else {
		cout << 3;
		}

		return 0;

	}

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

using namespace std;
using ll = long long;

double expected_value(int n) {
  return (double)((1 + n) * n / 2) / (double)n;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> ps(n);
  int p;
  rep(i, n) {
    cin >> p;
    ps[i] = expected_value(p);
  }
  double sum = 0;
  for (int i = 0; i < k; i++) {
    sum += ps[i];
  }
  double mm = sum;
  for (int i = 1; i <= n - k; i++) {
    sum -= ps[i - 1];
    sum += ps[i + k - 1];
    mm = max(sum, mm);
  }
  printf("%.6f\n", mm);
  return 0;
}

Measured memory_bytes: 4820
h,w = map(int,input().split())

if h == 1:
    print(1)
elif w == 1:
    print(1)
else:

    if w%2 == 0:
        a = w//2
        b = w//2
    else:
        a = w//2 + 1
        b = w//2

    if h%2 == 0:
        c = h//2
        d = h//2
    else:
        c = h//2 + 1
        d = h//2

    print(a*c + b*d)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int a,b;
	cin>>a>>b;
	if((a+b)%2==0)std::cout << (a+b)/2 << std::endl;
	else std::cout << "IMPOSSIBLE" << std::endl;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] dish = new int[5];
        int maxIndex = 0;
        int max = 0;
        int sum = 0;
        for (int i = 0; i < 5; i++) {
            dish[i] = sc.nextInt();
        }
        for (int i = 0; i < 5; i++) {
            int order = dish[i];
            while (order >= dish[i] && order % 10 != 0) {
                order++;
            }
            if (max < order - dish[i]) {
                max = order - dish[i];
                maxIndex = i;
            }
        }
        for (int i = 0; i < 5; i++) {
            if (i == maxIndex) continue;
            if (dish[i] % 10 != 0) {
                while (dish[i] % 10 != 0) {
                    dish[i]++;
                }
            }
        }
        for (int tmp : dish) {
            sum += tmp;
        }
        System.out.println(sum);
    }
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];

    bool able = false;
    REP(i, n) REP(j, n) if(s[i][j]=='#') able = true;
    if(!able) {
        cout << -1 << endl;
        return 0;
    }

    ll cnt = 0;
    REP(i, n) {
        bool flag = false;
        REP(j, n) if(s[j][i]=='.') flag = true;
        if(flag) cnt++;
    }
    // cout << "cnt=" << cnt << endl;

    ll ret = LLINF;
    REP(i, n) {
        // i行目を#にする
        bool flag = false;
        REP(j, n) if(s[j][i] == '#') flag = true;
        ll num = 0;
        if(!flag) num++;
        REP(j, n) if(s[i][j] == '.') num++;
        // cout << "i=" << i << " " << num << endl;
        chmin(ret, num);
    }

    cout << ret + cnt << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second

using namespace std;

ll gcd(ll n1,ll n2){
	if(!n1)return n2;
	if(!n2)return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	base%=mod;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	ans%=mod;
	return ans;
}
ll solve(ll n,ll x){
	if(n==-1)return -1;
	return (n/x);
}
int main()
{
	ll a,b,k;
	cin>>a>>b>>k;
	ll answer=solve(b,k)-solve(a-1,k);
	cout<<answer<<endl;
	return 0;
}


Measured memory_bytes: 384
#-*- coding:utf-8 -*-


def judge(a,n):
    a.sort()
    del a[0]
    del a[-1]
    sum = 0
    for i in range(len(a)):
        sum += a[i]
    return int(sum / len(a))

while(1):
    n = int(input())
    if (n == 0):
        exit(0)
    else:
        a = [int(input()) for i in range(n)]
        print(judge(a,n))

Measured memory_bytes: 7668
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll gcd(ll a, ll b){//計算量はO(log(max(a,b))
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int N, K;
vector<int> A;

bool p(int x){
  bitset<5000> bset;
  bset[0] = 1;
  rep(i, N){
    if(i == x) continue;
    bset |= (bset << A[i]);
  }
  for(int i = K - A[x]; i < K; i++){
    if(bset[i]) return true;
  }
  return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  rep(i, N){
    int a; cin >> a;
    if(a < K) A.push_back(a);
  }
  sort(A.begin(), A.end());
  N = A.size();
  int no = -1, need = N;
  while(need - no > 1){
    int mid = (no + need) / 2;
    if(p(mid)) need = mid;
    else no = mid;
  }
  cout << no + 1 << endl;
  
}


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

#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 FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#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 int long long
#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 ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

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


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




long long rui(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b & 1)
      ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}

long long comb(long long a, long long b){
  long long ans = 1;
  for (long long i = a; i > a - b; i--){
    ans = ans * i % MOD;
  }
  for (long long i = 1; i <= b; i++){
    ans = (ans * rui(i, MOD - 2)) % MOD;
  }
  return ans;
}

ll cnt[10];



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n;
  string s;
  cin>>n>>s;
  int ans=0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        int l=0;
        while(l<n){
          if(s[l]=='0'+i){
            l++;
            break;
          }
          l++;
        }
        while(l<n){
          if(s[l]=='0'+j){
            l++;
            break;
          }
          l++;
        }
        bool flg=false;
        while(l<n){
          if(s[l]=='0'+k){
            flg=true;
            l++;
            break;
          }
          l++;
        }
        if(flg) ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, w, n, d, ans=0;
    cin >> h >> w >> n;
    d=max(h, w);
    if(n%d==0) ans=n/d;
    else ans=n/d+1;
    cout << ans <<endl;


    
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll A, B;
  std::cin >> A>>B;

  if (B%A == 0) {
    std::cout << A+B << '\n';
  }else{
    std::cout << B-A << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
import math
n, d = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
    if math.sqrt(xy[i][0] ** 2 + xy[i][1] ** 2) <= d:
        ans += 1
print(ans)

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    int m = (a+b) - n;
    m = max(0,m);
    cout << min(a,b) << " " << m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <map> 
#include <queue> 
#include <set> 
#include <stack>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ll long long

int main(){
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else if (s[0] == s[2] && s[2] != s[1] && s[1] == s[3]) cout << "Yes" << endl;
    else if (s[0] == s[3] && s[3] != s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
//	??´?§?????§???¢ 
#include<iostream>
using namespace std;

int main() {
	int a,b,c,n;
	cin >> n;
	for ( int i=0; i < n; i++ ){
		bool flag = false;
		cin >> a >> b >> c;
		if (a + b > c && a + c > b && b + c > a){
			if ( ((a*a + b*b) == c*c) ||  ((a*a + c*c) == b*b) || ((b*b + c*c) == a*a) ){
				flag = true;
			}
		}
		if (flag) {
			cout << "YES" << endl;
		}else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 double PI = acos(-1);

int main() {
    double r; cin >> r;
    cout << fixed << setprecision(10) << 2 * PI * r << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll mod=1000000007;
int main()
{
  ll a,b,c,d,i,j,k,l,m,n;
  ll sum=0,ans=0;
  cin>>n;
  ll arr[n];
  for(i=0;i<n;i++)cin>>arr[i];
  for(i=0;i<n;i++)sum+=arr[i],sum%=mod;
  for(i=0;i<n-1;i++)
  {
    sum-=arr[i];
    sum+=mod;
    sum%=mod;
    ans+=(arr[i]*sum);
    ans+=mod;
    ans%=mod;
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int d=365, n=26, score;
int c[27];
int s[366][27];
int a[366];
int sat[366]={};
int last[27]={};
ofstream fout("out.txt"), flog("log.txt");
uint64_t get_rand_range( uint64_t min_val, uint64_t max_val ) {

    srand((int)time(NULL));
    static mt19937_64 mt64(rand());

    uniform_int_distribution<uint64_t> get_rand_uni_int( min_val, max_val );

    return get_rand_uni_int(mt64);
}

int calcdiff(int t, int q){
    int p=a[t];
    int lp=0,rp=d+1,lq=0,rq=d+1;
    For(i,1,d+1){
        if(a[i]==p){
            if(i<t) lp=max(lp,i);
            else if(i>t) rp=min(rp,i);
        }
        if(a[i]==q){
            if(i<t) lq=max(lq,i);
            else if(i>t) rq=min(rq,i);
        }
    }
    int diff=s[t][q]-s[t][p];
    diff -= (t-lp) * (rp-t) * c[p];
    diff += (t-lq) * (rq-t) * c[q];
    return diff;
}

void greedy(){
    For(i,1,d+1){
        int mx = -(1<<30), acc = -1;
        For(con,1,n+1){
            int sati = sat[i-1] + s[i][con];
            For(j,1,n+1){
                if(j != con) sati -= (i-last[j]) * c[j];
            }
            if(mx<sati){
                mx = sati;
                acc = con;
            }
        }
        last[acc] = i;
        sat[i] = mx;
        a[i]=acc;
    }    
    score = sat[d];
}

void Main(){
    clock_t start = clock();
    cin >> d;
    For(i,1,n+1) cin >> c[i];
    For(i,1,d+1) For(j,1,n+1) cin >> s[i][j];
    greedy();
    double time = static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0;
    while(time < 1950){
        int t = get_rand_range(1,d);
        int q = a[t];while(q==a[t])q=get_rand_range(1,n);
        int diff = calcdiff(t,q);
        //flog << diff << endl;
        if(diff>0){
            a[t] = q;
            score += diff;
        }
        time = static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0;
    }
    For(i,1,d+1) cout << a[i] << endl;

}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main ()
{
   int h;
   int n;
   int i;
   int dam=0;
   int a;
   scanf("%d %d",&h,&n);
   for(i=0;i<n;i++)
   {
       scanf("%d",&a);
       dam+=a;
   }
   if(dam>=h) printf("Yes");
   else printf("No");

   return 0;
}

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

int a[1000], top;

void push(int n) {
  a[top++] = n;
}


int pop() {
  return a[--top];
}


int main() {
  char ch[100];
  int n1, n2;
  top = 0;

  while (scanf("%s", ch) != EOF) {
    if (ch[0] == '+') {
      n1 = pop();
      n2 = pop();
      push(n1 + n2);
    } else if (ch[0] == '-') {
      n1 = pop();
      n2 = pop();
      push(n2 - n1);
    } else if (ch[0] == '*') {
      n1 = pop();
      n2 = pop();
      push(n1 * n2);
    } else {
      push(atoi(ch));
    }
  }

  printf("%d\n", pop());

  return 0;
}



Measured memory_bytes: 2080
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res=0
for  i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500*i + 100*j + 50*k == X:
                res += 1
print(res)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		String S = in.next();
		
		if (S.length() != N) throw new IllegalArgumentException();
		int AB = A + B;
		
		for(int i=0; i<N; i++) {
			char c = S.charAt(i);
			
			if (c == 'a' && AB > 0) {
				System.out.println("Yes");
				AB--;
			} else if (c == 'b' && AB > 0 && B>0) {
				System.out.println("Yes");
				AB--; B--;
			} else {
				System.out.println("No");
			}
		}

	}

}


Measured memory_bytes: 23472
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int n,k;
string s;
int main(int argc, char const *argv[])
{
	cin>>n>>k>>s;
	int now = 0;
	for(int i = 0;i < n; ++i)
	{
		if(s[i] == 'L')
		{
			if(!(i == 0 || s[i - 1] != 'L'))
			{
				now++;
			}
		}
		else
		{
			if(!(i == n - 1 || s[i + 1] != 'R'))
			{
				now++;
			}
		}
	}
	cout<<min(n - 1,now + 2 * k)<<endl;
	return 0;
}

Measured memory_bytes: 512