akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

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

  int c1 = 1;
  int c2 = 0;
  for(int i = 1; i < s.length(); i++){
    if(i % 2 == 0){
        c1 = s[0] == s[i] ? c1 + 1 : c1;
        c2 = s[0] != s[i] ? c2 + 1 : c2;
    }else {
        c1 = s[0] != s[i] ? c1 + 1 : c1;
        c2 = s[0] == s[i] ? c2 + 1 : c2;
    }
  }
  
  cout << min(c1, c2);
  return 0;
}



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

const int id = 0;

int op(int l, int r) {
	return l + r;
}

struct node {
	int pos, val, all;
	node *lch, *rch;
	node(int p, int v)
		: pos(p), val(v), all(v), lch(nullptr), rch(nullptr) {}
};

void update_up(node* t) {
	t->all = op(op((t->lch ? t->lch->all : id), t->val), (t->rch ? t->rch->all : id));
}

node *update(node* t, int p, int val, int lb, int ub) {
	if (!t) return new node(p, val);
	if (t->pos == p) {
		t->val += val;
		update_up(t);
		return t;
	}
	int m = (lb + ub) >> 1;
	if (p < m) {
		if (t->pos < p) {
			swap(t->pos, p);
			swap(t->val, val);
			update_up(t);
		}
		t->lch = update(t->lch, p, val, lb, m);
	}
	else {
		if (t->pos > p) {
			swap(t->pos, p);
			swap(t->val, val);
			update_up(t);
		}
		t->rch = update(t->rch, p, val, m, ub);
	}
	update_up(t);
	return t;
}

int find(node* t, int l, int r, int lb, int ub) {
	if (!t || r <= lb || ub <= l) return id;
	if (l <= lb && ub <= r) return t->all;
	int m = (lb + ub) >> 1;
	int val = l <= t->pos && t->pos < r ? t->val : id;
	return op(op(find(t->lch, l, r, lb, m), val), find(t->rch, l, r, m, ub));
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	node *seg = nullptr;
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y; x--;
		if (com == 0) {
			seg = update(seg, x, y, 0, n);
		}
		else {
			printf("%d\n", find(seg, x, y, 0, n));
		}
	}
	return 0;
}



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

int N, M;

int s[101010];
int t[101010];

int p[101010];

ll imos_even[101010];
ll imos_odd[101010];

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

	while (cin >> N >> M)
	{
		rep(i, 0, N) cin >> s[i] >> t[i];
		rep(i, 0, M) cin >> p[i];

		p[M] = INT_MAX / 2;
		//cout << p[M] << endl;
		sort(p, p + M + 1);

		rep(i, 0, M + 1) imos_even[i] = imos_odd[i] = 0;

		imos_even[0] = p[0];
		rep(i, 1, M + 1)
		{
			if (i % 2 == 0)
				imos_even[i] = p[i] - p[i - 1];
			else
				imos_odd[i] = p[i] - p[i - 1];
		}
		rep(i, 1, M + 1) imos_even[i] += imos_even[i - 1];
		rep(i, 1, M + 1) imos_odd[i] += imos_odd[i - 1];

		ll ans = 0;
		rep(i, 0, N)
		{
			auto s_ite = upper_bound(p, p + M + 1, s[i]);
			int si = s_ite - p;
			auto t_ite = upper_bound(p, p + M + 1, t[i]);
			int ti = t_ite - p;

			//cout << i << endl;
			//cout << "p[" << si << "]=" << *s_ite << endl;
			//cout << "p[" << ti << "]=" << *t_ite << endl;

			if (si == ti)
			{
				ans += abs((ll)(t[i] - s[i]));
				continue;
			}

			int mod2 = si % 2;

			ll *imos;
			if (mod2 == 0)
				imos = imos_even;
			else
				imos = imos_odd;

			if (si > ti)
			{
				swap(si, ti);
				swap(s[i], t[i]);
			}

			if (si == 0)
			{
				ans += (ll)(imos[ti]);
				if (si % 2 == mod2) ans -= s[i];
				if (ti % 2 == mod2) ans -= (ll)p[ti] - t[i];
			}
			else
			{
				ans += (ll)(imos[ti] - imos[si - 1]);
				if (si % 2 == mod2) ans -= s[i] - (ll)p[si - 1];
				if (ti % 2 == mod2) ans -= (ll)p[ti] - t[i];
			}

			//cout << "ans=" << ans << endl;
			//cout << endl;
		}

		cout << ans << endl;
	}
}

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

int main(void) {
  int i, j, n, u, k, v;
  int **ptr;
  scanf("%d", &n);
  ptr = calloc(n, sizeof(int*));
  for (i = 0; i < n; i++) {
    ptr[i] = calloc(n, sizeof(int));
  }
  
  while (1) {
    scanf("%d %d", &u, &k);
    for (i = 0; i < k; i++) {
      scanf("%d", &v);
      ptr[u-1][v-1] = 1;
    }
    if (u == n) {
      break;
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (j == n-1) {
        printf("%d", ptr[i][j]);
        break;
      }
      printf("%d ", ptr[i][j]);
    }
    printf("\n");
  }

  for (i = 0; i < n; i++) {
    free(ptr[i]);
  }
  free(ptr);

  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <map>
#include <string>

using namespace std;

class Dice {
	public:
		map<char, int> dice;
		Dice(int _I, int _II, int _III, int _IV, int _V, int _VI);
		int GetNumber(char c);
		void roll_E();
		void roll_N();
		void roll_S();
		void roll_W();
};

Dice::Dice(int _I, int _II, int _III, int _IV, int _V, int _VI) {
	dice['T'] = _I;
	dice['S'] = _II;
	dice['E'] = _III;
	dice['W'] = _IV;
	dice['N'] = _V;
	dice['B'] = _VI;
}

int Dice::GetNumber(char c) {
	return dice[c];
}

void Dice::roll_E() {
	map<char, int> tmp = dice;	
	dice['T'] = tmp['W'];
	dice['E'] = tmp['T'];
	dice['W'] = tmp['B'];
	dice['B'] = tmp['E'];
}

void Dice::roll_N() {
	map<char, int> tmp = dice;	
	dice['T'] = tmp['S'];
	dice['S'] = tmp['B'];
	dice['N'] = tmp['T'];
	dice['B'] = tmp['N'];
}

void Dice::roll_S() {
	map<char, int> tmp = dice;	
	dice['T'] = tmp['N'];
	dice['S'] = tmp['T'];
	dice['N'] = tmp['B'];
	dice['B'] = tmp['S'];
}

void Dice::roll_W() {
	map<char, int> tmp = dice;	
	dice['T'] = tmp['E'];
	dice['E'] = tmp['B'];
	dice['W'] = tmp['T'];
	dice['B'] = tmp['W'];
}

int main() {
	int I, II, III, IV, V, VI;
	cin >> I >> II >> III >> IV >> V >> VI;
	Dice d(I, II, III, IV, V, VI);

	int op_num;
	cin >> op_num;
	for (int i = 0; i < op_num; i ++) {
		int top, south;
		cin >> top >> south;
		char posi;
		for (auto itr = d.dice.begin(); itr != d.dice.end(); itr++) {
			if (itr->second == top) {
				posi = itr->first;
			}
		}
		if (posi == 'S') {
			d.roll_N();
		} else if (posi == 'E') {
			d.roll_W();
		} else if (posi == 'W') {
			d.roll_E();
		} else if (posi == 'N') {
			d.roll_S();
		} else if (posi == 'B') {
			d.roll_N();
			d.roll_N();
		}
		for (auto itr = d.dice.begin(); itr != d.dice.end(); itr++) {
			if (itr->second == south) {
				posi = itr->first;
			}
		}
		if (posi == 'S') {
			cout << d.dice['E'] << endl;
		} else if (posi == 'E') {
			cout << d.dice['N'] << endl;
		} else if (posi == 'W') {
			cout << d.dice['S'] << endl;
		} else if (posi == 'N') {
			cout << d.dice['W'] << endl;
		}
	}

	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}



Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int main(void){
    
    int a, b, c;
    int ab, ac, bc;
    
    cin >> a >> b >> c;
    
    ab = a + b;
    ac = a + c;
    bc = b + c;
    
    if(ab <= ac && ab <= bc) cout << ab << endl;
    else if(ac <= ab && ac <= bc) cout << ac << endl;
    else cout << bc << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (a, b) = (line[0], line[1]);

    println!("{}", (a-1)*(b-1));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
const int N = (int)(1*1e6+10);
typedef long long ss;
int main()
{
   int i,j,n,m;
   cin>>n>>m;
   if(m%2==1)
   {
       cout<<"No"<<endl;
       return 0;
   }
   if(n*2>m)
   {
       cout<<"No"<<endl;
       return 0;
   }
   if(n*4>=m)
   {
       cout<<"Yes"<<endl;
       return 0;
   }
   cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double PI=3.14159265358979323846;

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

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

int main(){
  int n;
  cin >> n;
  int a[n];
  int ma = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    ma = max(ma, a[i]);
  }
  int num = a[0];
  for(int i = 0; i < n-1; i++){
    num = lcm(num, a[i+1]);
  }
  while(num < ma){
    num += num;
  }
  int m = 0;
  for(int i = 0; i < n; i++){
    int temp = num / a[i];
    m += temp;
  }
  double ans = (double)num / m;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int M = 1e9 + 7;

int p[100005], pp[100005];

int32_t main()
{
	IO_OP;
	p[0] = 1;
	for(int i=1;i<100005;i++)
		p[i] = 3 * p[i-1] % M;
	pp[0] = 1;
	for(int i=1;i<100005;i++)
		pp[i] = 2 * pp[i-1] % M;
	string s;
	cin >> s;
	int x = 0;
	int n = s.size(), ans = 0, j = 0;
	for(int i=0;i<n;i++) { // i: len
		if(s[i] == '0') continue;
		ans += p[n-i-1] * pp[j] % M;
		ans %= M;
		j++;
	}
	ans += pp[j];
	ans %= M;
	cout << ans << endl;

}



Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <thread>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, ans, a2[110000];
bool used[110000];
vector<ll> g[110000];
map<P, ll> mp;


void dfs(ll a, ll b) {
	ll now = 1;
	ans = max(ans, b);
	used[a] = true;
	REP(i, g[a].size()) {
		if (used[g[a][i]])continue;
		if (now == b)now++;
		a2[mp[P(a, g[a][i])]] = now;
		dfs(g[a][i], now);
		now++;
	}
}

int main() {
	cin >> n;
	REP(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
		mp[P(a, b)] = i;
		mp[P(b, a)] = i;
	}
	dfs(0, 0);
	cout << ans << endl;
	REP(i, n - 1) {
		cout << a2[i] << endl;
	}
}


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

using namespace std;

#define pb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define pii pair<int, int>

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for (auto &c : a) cin >> c;
    for (auto &c : b) cin >> c;
    ll now = 0;
    for (auto &c : a) now += c;
    int j = 0, ans = 0;
    for (int i = n; i >= 0; i--) {
        if (i < n) now -= a[i];
        while (j < m && now + b[j] <= k) {
            now += b[j];
            j++;
        }
        if (now <= k) ans = max(ans, i + j);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll i,j,n,a,b;
  priority_queue<P> que;
  priority_queue<ll> q[300010];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    for(j=0;j<a;j++){
      cin >> b;
      q[i].push(b);
    }
  }
  ll ans=0;
  for(i=n-1;i>=0;i--){
    if(!q[i].empty()){
      que.push(P(q[i].top(),i));
    }
    if(que.empty()){
      continue;
    }
    P s=que.top();
    ans+=s.first;
    q[s.second].pop();
    que.pop();
    if(!q[s.second].empty()){
      que.push(P(q[s.second].top(),s.second));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 21828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if (a < b) {
			
			System.out.println("a < b");
		}
		
		else if (a > b) {
			System.out.println("a > b");
			
		}
		
		else if (a == b) {
			System.out.println("a == b");
			
		}
	}
}



Measured memory_bytes: 26204
#include<stdio.h>
#include<string.h>
#define LEN 100005
#define MAX 100000

int initialize(void);
int isEmpty(void);
int isFull(void);

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  if(isFull()) printf("Overflow\n");
  Q[tail] = x;
  if(tail+1 == MAX) tail = 0;
  else tail++;
}

P dequeue(){
  P x;
  if(isEmpty()) printf("Underflow\n");
  x = Q[head];
  if(head+1 == MAX) head = 0;
  else head++;
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n+1;
  while(n!=0){
    u = Q[head];
    u.t = Q[head].t-q;
    if(u.t>0){
      elaps = elaps+q;
      enqueue(u);
      Q[head] = dequeue();
    }
    else{
      elaps = elaps+Q[head].t;
      printf("%s %d\n",u.name,elaps);
      Q[head] = dequeue();
      n--;
    }
  }
  return 0;
}
int initialize(void){
  head = tail = 0;
}
int isEmpty(void){
  if(head == tail) return 1;
  else return 0;
}
int isFull(void){
  if(head == (tail+1) % MAX) return 1;
  else return 0;
}

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

void q74() {
	int t, h, s;
	for (; cin >> t >> h >> s;) {
		if (t == -1) break;
		int sec = 2 * 60 * 60 - t * 60 * 60 - h * 60 - s;
		printf("%02d:%02d:%02d\n", sec / 60 / 60, (sec / 60) % 60, sec % 60);
		sec *= 3;
		printf("%02d:%02d:%02d\n", sec / 60 / 60, (sec / 60) % 60, sec % 60);
	}
}
int main() {
	q74();
	return 0;
}

Measured memory_bytes: 3136
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void BichromeCells() {
	int n, a;
	cin >> n;
	cin >> a;

	cout << (n * n - a) << endl;
}
int main() {

	BichromeCells();
	return 0;
}


Measured memory_bytes: 256
n= input()
count = 0
if len(n)%2 == 0:
  for i in range(1,len(n),2):
    count += (9 * (10**(i-1)))
else:
  for i in range(1, len(n)-1,2):
    count += (9 * (10**(i-1)))
  count += (int(n)-(10**(len(n)-1))+1)

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 200005
#define mod 998244353
using namespace std;

typedef pair<int, int> P;

ll n;
ll k;
ll a[maxn], idx[maxn];
const ll LOG = 60;
ll add[LOG][maxn];

vector<ll> ans;
int cnt[maxn];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        scanf("%lld", &a[i]);

    for (int i = n - 1; i >= 0; i--)
        idx[a[i]] = i;
    for (int i = n - 1; i >= 0; i--)
    {
        if (idx[a[i]] <= i)
            add[0][i] = idx[a[i]] + n - i + 1;
        else
            add[0][i] = idx[a[i]] - i + 1;
        idx[a[i]] = i;
    }

    for (int i = 1; i < LOG; i++)
        for (int j = 0; j < n; j++)
        {
            add[i][j] = add[i - 1][(add[i - 1][j] + j) % n] + add[i - 1][j];
            if (add[i][j] > n * k + 2)
                add[i][j] = n * k + 2;
        }

    ll now = 0;
    for (int i = LOG - 1; i >= 0; i--)
    {
        while (now + add[i][now % n] <= k * n)
            now += add[i][now % n];
    }
    //printf("%lld\n", add[LOG - 1][0]);
    //printf("%lld\n", now);
    if (now == k * n)
        return 0;

    for (ll i = now; i <= n * k - 1; i++)
    {
        ll x = i % n;
        if (cnt[a[x]] == 0)
        {
            ans.push_back(a[x]);
            cnt[a[x]]++;
        }
        else
        {
            while (cnt[a[x]] > 0)
            {
                cnt[ans.back()]--;
                ans.pop_back();
            }
        }
    }
    for (int i = 0; i < ans.size(); i++)
        printf("%lld ", ans[i]);
    return 0;
}


Measured memory_bytes: 100848
N = int(input())
H = list(map(int, input().split()))

dp = [10**9]*N
dp[0] = 0
for i in range(N):
    if i+1 <= N-1:
        dp[i+1] = min(dp[i+1], dp[i]+abs(H[i+1]-H[i]))
    if i+2 <= N-1:
        dp[i+2] = min(dp[i+2], dp[i]+abs(H[i+2]-H[i]))
print(dp[N-1])


Measured memory_bytes: 13924
#include <iostream>
#include <sstream>  // istringstream
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{   
    // 練習でやった問題, 逆から探索する
    int N;
    cin >> N;
    int T[N];
    for(int i=0; i<N; ++i) cin >> T[i];
    int M;
    cin >> M;
    int P[M], X[M];
    for(int i=0; i<M; ++i) cin >> P[i] >> X[i];
    
    int ans[M];

    for(int i=0; i<M; ++i){
        ans[i] = X[i] - T[P[i]-1];
        for(int j=0; j<N; ++j){
            ans[i] += T[j];
        }
    }

    for(int i=0; i<M; ++i){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]
c = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
    ans = 0
    dis = 10**9
    for j in range(M):
        if dis > abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]):
            ans = j+1
            dis = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
    print(ans)

Measured memory_bytes: 3064
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, m;
long a[1005], b[1005];
long openable[1005];

long cost[1005][1<<12];

int main(){
    scanf("%ld%ld", &n, &m);
    for(int i = 1; i <= m; i++){
        scanf("%ld%ld", a+i, b+i);
        for(int j = 1; j <= b[i]; j++){
            long x;
            scanf("%ld", &x);
            openable[i] |= (1 << (x-1));
        }
        //std::cout << std::bitset<12>(openable[i]).to_string() << std::endl;
    }
    for(long j = 0; j < (1 << n); j++){
        cost[0][j] = LINF;
    }
    cost[0][0] = 0;
    for(long i = 1; i <= m; i++){
        for(long j = 0; j < (1 << n); j++){
            cost[i][j] = std::min(cost[i-1][j], cost[i-1][j & (~openable[i])] + a[i]);
        }
    }
    /*
    for(long j = 0; j < (1 << n); j++){
        std::cout << std::bitset<4>(j).to_string();
        printf("  %ld\n", cost[m][j]);
    }
    //*/
    long ans = cost[m][(1 << n) - 1];
    if(ans == LINF){
        printf("-1\n");
    }else{
        printf("%ld\n", ans);
    }
}


Measured memory_bytes: 32256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k;
  cin>>n>>k;
  if(n<=2){
    cout<<0<<endl;
    return 0;
  }
  int h=11,w=5;
  int m1=0;
  for(i=1;i<=h;i++)for(j=1;j<=w;j++){
    int sum=0;
    int x,y;
    rep(x,3)rep(y,3)
      sum+=7*(i+x)+(j+y)-7;
    if(sum%11==k)m1++;
  }
  h=(n+11-2)%11;
  int m2=0;
  for(i=1;i<=h;i++)for(j=1;j<=w;j++){
      int sum=0;
      int x,y;
      rep(x,3)rep(y,3)
	sum+=7*(i+x)+(j+y)-7;
      if(sum%11==k)m2++;
    }
  if(n%11<2)
    cout<<m1*(n/11-1)+m2<<endl;
  else 
    cout<<m1*(n/11)+m2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a == c) P(1);
  else if ((a == b && a != c) || (a != b && b == c) || (a == c && a != b)) P(2);
  else P(3);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

#define N (10000000)
int p[10000001];
int f(){
	p[0] = p[1] = 1;
	for(int i = 2 ; i*i <= N ; i++)
		if(!p[i]){
			for(int j = i*i ; j <= N ; j+=i)
				p[j] = 1;
		}
}
int main(){
	int n;
	f();
	while(cin >> n && n){
		int r = n;
 		while(r){
			if(!p[r] && !p[r-2] && !p[r-6]&& !p[r-8]){
				cout << r << endl;
				break;
			}
			r--;
		}
	}
}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)

func StrStdin() (stringInput string){
  sc.Scan()
  OneLineString := sc.Text()
  stringInput = strings.TrimSpace(OneLineString)
  return 
}

func IntStdin() (int, error){
  stringInput := StrStdin()
  return strconv.Atoi(stringInput)
}

// �󔒂�󕶎������̒l����������Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

func SplitStrStdin(delim string) (stringReturned []string) {
    stringInput := StrStdin()
  
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

func SplitIntStdin(delim string) (intSlices []int, err error) {
    stringSplited := SplitStrStdin(delim)
	
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func main(){
  first,error := SplitIntStdin(" ")
  
  result := 1
  if error == nil {
    for _, value := range first {
      result *= value
    }
  }
  
  a := result % 2
  
  if a == 0 {
    fmt.Println("Even")
  }else{
    fmt.Println("Odd")
  }
  
}


Measured memory_bytes: 640
x, y = map(int, input().split())

a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c :
    print("Yes")
else:
    print("No")

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

int N;
vector<string> input;
int level;
char c;
int idx;
bool next(){
	idx++;
	if(idx <= N){
		string str;
		cin >> str;
		level = str.length() - 1;
		c = str[str.length() - 1];
		return true;
	}
	return false;
}

int recur(int l){
	if(c == '+'){
		int val = 0;
		next();
		while(idx <= N){
			if(l > level){
				break;
			}else if(c == '+' || c == '*'){
				val += recur(l + 1);
			}else{
				val = val + (c - '0');
				next();
			}
		}
		return val;

	}else if(c == '*'){
		int val = 1;
		next();
		while(idx <= N){
			if(l > level){
				break;
			}else if(c == '+' || c == '*'){
				val *= recur(l + 1);
			}else{
				val = val * (c - '0');
				next();
			}	
		}
		return val;

	}else{
		return c - '0';
	}
}

int main(){
	while(cin >> N, N){
		idx = 0;
		next();
		cout << recur(1) << endl;
	}
}

Measured memory_bytes: 1212
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
LL h, w, n, m, ans[12] = {}, d[100] = {}, a[10][10] = {}, f[200][200] = {}, sum = 0;
int flag = 0;
string str;
void DIUX(LL s) {
	for (int i = 0; i < 100; i++)
		d[i] = INF;
	d[s] = 0;
	priority_queue<Pll, vector<Pll>, greater<Pll>> pq;
	pq.push(make_pair(d[s], s)); // (cost,頂点番号) 
	while (!pq.empty()) {
		Pll pp;
		pp = pq.top();
		LL cos = pp.first, vv = pp.second;
		pq.pop();
		if (d[vv] < pp.first)continue;
		for (int i = 0; i < 10; i++) {
			if (i != vv) {

				if (a[vv][i] + d[vv] < d[i]) {
					d[i] = a[vv][i] + d[vv];
					pq.push(make_pair(d[i], i));
				}

			}
		}
	}
}
int main(){
	cin >>h>>w ;
	for(int i=0;i<10;i++)
		for (int j = 0; j < 10; j++) {
			cin >> a[i][j];
		}
	for (int i = 0; i < 10; i++) {
		DIUX(i);
		ans[i] = d[1];
	}
	for (int i = 0; i<h; i++)
		for (int j = 0; j < w; j++) {
			cin >> f[i][j];
			if(f[i][j]!=-1)
			sum += ans[f[i][j]];
		}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;

ll f(ll a,ll b,ll x){
  ll ans;
  ans=(a*x)/b-a*(x/b);
  return ans;
}

int main() {
  ll a,b,N;
  cin>>a>>b>>N;
  if(b<=N){
    cout<<f(a,b,b-1);
  }
  else{
    cout<<f(a,b,N);
  }
  
      
      
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int unsigned a;
	int unsigned b;
	int unsigned c;
	int unsigned i = 0;

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

	if( a<0 || a>10000 || b<0 || b>10000 || c<0 || c>10000 || a > b )
	{
		return 1;
	}

	while( a <= b )
	{
		if( c%a == 0 )
		{
			i++;
		}

		a++;
	}


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

	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int a[31][31]={};
int main()
{
   int n,m;
   int x;
   scanf("%d%d",&n,&m);
   int k;
   for (int i=1;i<=n;i++)
   {
       scanf("%d",&k);
       for (int j=1;j<=k;j++)
       {
           scanf("%d",&x);
           a[i][x]=1;
       }
   }
   int sum=0;
   for (int i=1;i<=m;i++)
   {
       bool flag=1;
       for (int j=1;j<=n;j++)
       {
           if(!a[j][i])
           {
               flag=0;
               break;
           }
       }
       if (flag) sum++;
   }
   printf("%d",sum);
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){
  int n,q,S[100000],T[50000];
  int i,count=0,left,right,mid;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);
  
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(T[i]==S[mid]){
	count++;
	break;
      }
      else if (T[i]>S[mid])
	left=mid+1;
      else if (T[i]<S[mid])
	right = mid;
    }
    
  }
  
  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2280
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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 main(){ 
    int a, b; cin >> a >> b;
    int res = a*b - (a+b-1);
    cout << res << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y>a.y;
        return max(x,-x)>max(a.x,-a.x);

    }

};
vector<int> v[1];
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
int o[11];
int l[1];
int j[1];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s,s1;

//priority_queue<int> q;
queue<int> q;
//string r1;
char r[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());
/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    //if(a.y!=b.y)
    //return a.y>b.y;
    return a.x<b.x;
}


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

int main()
{
    for(int t=0;t<3;t++)
        //puts("@");
        scanf("%d ",&o[t]);
    sort(o+0,o+3);
    if(o[2]==o[0]) puts("Yes");
    else puts("No");

}


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

int main() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    for (ll& e : p) cin >> e;
    for (ll& e : q) cin >> e;
    for (ll& e : r) cin >> e;
    sort(p.rbegin(), p.rend());
    while (p.size() > x) p.pop_back();
    sort(q.rbegin(), q.rend());
    while (q.size() > y) q.pop_back();
    sort(r.rbegin(), r.rend());
    while (r.size() > x + y) r.pop_back();
    vector<ll> vec;
    for (ll& e : p) vec.push_back(e);
    for (ll& e : q) vec.push_back(e);
    for (ll& e : r) vec.push_back(e);
    sort(vec.rbegin(), vec.rend());
    ll ans = 0;
    for (int i = 0; i < x + y; i++)
        ans += vec[i];
    cout << ans << endl;
}

Measured memory_bytes: 8688
N=int(input())
A=list(map(int,input().split()))
e=1
for i in A:
    if i%2==0:
        e*=2#奇数が2パターンある
    else:
        e*=1#奇数が1パターンある
print(3**N-e)#全通り ー 積が奇数の組

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int ans = 1;
  int i = 0;
  while ( i < N ){
    if ( ans < K ){
      ans = ans * 2;
      i++;
    }
    else {
      ans = ans + K;
      i++;
    }
  }
  cout << ans << endl;
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	string s ;
	int cnt0 = 0 , cnt1 = 0 , cnt2 = 0 , cnt3 = 0 ;
	while(n--)
	{
		cin>>s ;
		if(s == "AC")
			cnt0++ ;
		if(s == "WA")
			cnt1++ ;
		if(s == "TLE")
			cnt2++ ;
		if(s == "RE")
			cnt3++ ;
	}
	cout<<"AC x "<<cnt0<<"\n" ;
	cout<<"WA x "<<cnt1<<"\n" ;
	cout<<"TLE x "<<cnt2<<"\n" ;
	cout<<"RE x "<<cnt3<<"\n" ;
	return 0 ;
}		

Measured memory_bytes: 3656
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]

res = 0
for i in range(N):
    s = 0
    for j in range(i + 1):
        s += A[0][j]
    for k in range(i, N):
        s += A[1][k]
    res = max(res, s)
print(res)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
   int N;
   cin>>N;
   int i=0;
   long long int answer1=2;
   long long int answer2=1;
   while(i<=N){
       if(i==0)
           answer1=2;
       else if(i==1)
           answer2=1;
       else if(i%2==0)
           answer1=answer1+answer2;
       else 
           answer2=answer1+answer2;
       i++;
   }
   if(N%2==0)
       cout<<answer1<<endl;
   else
       cout<<answer2<<endl;
}


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

void Main()
{
    long a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k){
        cout << k << endl;
        return;
    }
    if(a + b >= k){
        cout << a << endl;
        return;
    }
    cout << a - (k - a - b) << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

using namespace std;

int main() {
	long long a; cin >> a;
	string b; cin >> b;
	cout << a * ((b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0')) / 100 << '\n';
	return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((ll)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((ll)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
 
ll n,k;
ll Main() {
    cin >> n >> k;
    vl a(n);
    
    rep(i,n) {
        cin >> a[i] ;
    }
    
    for(ll i=k-1; i<n-1; i++) {
        if(a[i-k+1] < a[i+1]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 4676
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  ll ans = 1;
  vector<int> num(3,-1);
  for(int i=0; i<N; i++){
    ll cnt = 0;
    for(int j=0; j<3; j++){
      if(A[i]-1 == num[j]){
        cnt++;
      }
    }
    for(int j=0; j<3; j++){
      if(A[i]-1 == num[j]){
        num[j]++;
        break;
      }
    }
    ans *= cnt;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j;
  cin>>n;
  
  vector<int> dp(n),h(n);

  for(i=0;i<n;i++){
    cin>>h[i];
  }
  
  for(i=0;i<n-1;++i){
    if(i!=0){
      dp[i+1]=min(dp[i]+abs(h[i]-h[i+1]),dp[i-1]+abs(h[i+1]-h[i-1]));
    }else{
      dp[i+1]=dp[i]+abs(h[i]-h[i+1]);
    }
  }
  
  cout<<dp[n-1]<<endl;
}
                        
  

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std ;

const int N=100 ;

double x[N] , y[N] ;
int p[N] ;
int n ;

inline double squ ( double x ) { return x*x; }
inline double dis ( int a , int b )
{
	return sqrt(squ(x[a]-x[b])+squ(y[a]-y[b]));
}

int main ()
{
	int i ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ )
		scanf("%lf%lf",x+i,y+i);
	for ( i=1 ; i<=n ; i++ )
		p[i]=i;
	double res=0 ;
	do
	{
		for ( i=2 ; i<=n ; i++ )
			res+=dis(p[i-1],p[i]);
	} while ( next_permutation(p+1,p+n+1) );
	for ( i=1 ; i<=n ; i++ )
		res/=(double)(i);
	printf("%.12lf\n",res);
	return 0 ;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

constexpr int mod = 1e9 + 7;

int ModPow(int x, int y) {
    if (y < 0) return 0;
    if (y == 0) return 1;
    long long a = ModPow(x, y / 2);
    if (y & 1) return a * a % mod * x % mod;
    else return a * a % mod;
}

int main() {
    string S;
    cin >> S;
    
    int hatena_cnt = 0;
    rep(i, S.size()) {
        if (S[i] == '?') ++hatena_cnt;
    }
    vector<vector<int>> cnt(S.size(), vector<int>(4, 0));
    if (S[0] == '?') cnt[0][3] = 1;
    else cnt[0][S[0] - 'A'] = 1;
    REP(i, S.size()) {
        rep(j, 4) cnt[i][j] = cnt[i - 1][j];
        if (S[i] == '?') ++cnt[i][3];
        else ++cnt[i][S[i] - 'A'];
    }
    
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] == 'A' || S[i] == 'C') continue;
        if (i == 0 || i == S.size() - 1) continue;
        
        int A = cnt[i - 1][0];
        int C = cnt[S.size() - 1][2] - cnt[i][2];
        int hatena_front = cnt[i - 1][3];
        int hatena_back = cnt[S.size() - 1][3] - cnt[i][3];
        long long res = 0;
        if (S[i] == 'B') {
            res += (long long)ModPow(3, hatena_cnt) * A * C;
            res += (long long)ModPow(3, hatena_cnt - 1) * hatena_front * C;
            res += (long long)ModPow(3, hatena_cnt - 1) * A * hatena_back;
            res += (long long)ModPow(3, hatena_cnt - 2) * hatena_front * hatena_back;
            ans = (ans + res) % mod;
        } else {
            res += (long long)ModPow(3, hatena_cnt - 1) * A * C;
            res += (long long)ModPow(3, hatena_cnt - 2) * hatena_front * C;
            res += (long long)ModPow(3, hatena_cnt - 2) * A * hatena_back;
            res += (long long)ModPow(3, hatena_cnt - 3) * hatena_front * hatena_back;
            ans = (ans + res) % mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double angle = Math.toRadians(sc.nextDouble());
        double c = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle));
        double L = a + b + c;
        double S = (a*b * Math.sin(angle))/2;
        double h = 2 * S / a;
        System.out.println(S);
        System.out.println(L);
        System.out.println(h);
    }
}



Measured memory_bytes: 27916
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int queueLength = scanner.nextInt();
        final int operation = scanner.nextInt();

        final List<Integer> queue = new LinkedList<>();

        for (int i = 0; i < queueLength; i++) {
            queue.add(scanner.nextInt());
        }

        final int counter = Math.min(queueLength, operation);
        int res = 0;

        for (int i = 0; i <= counter; i++) {
            for (int j = 0; j <= i; j++) {
                final LinkedList<Integer> clonedQueue = new LinkedList<>(queue);
                final List<Integer> selection = new ArrayList<>();
                for (int k = 0; k < j; k++) {
                    selection.add(clonedQueue.pollFirst());
                }
                for (int k = j; k < i; k++) {
                    selection.add(clonedQueue.pollLast());
                }
                Collections.sort(selection);
                for (int l = 0; l < operation - i; l++) {
                    if (selection.isEmpty()) {
                        break;
                    }

                    if (selection.get(0) < 0) {
                        selection.remove(0);
                    } else {
                        break;
                    }
                }

                final int sum = selection.stream().mapToInt(Integer::intValue).sum();
                if (sum > res) {
                    res = sum;
                }
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 29140
N,K = map(int, input().split())
A = list(map(int, input().split()))
graph = [0] * N
point = 1
count = 0
flag = True
while count < K:
  graph[point-1] += 1
  count += 1
  if flag and graph[point-1] >= 3:
    stock = K - sum(graph)-1
    stock2 = sum([1 for i in graph if i >= 2])
    K = (stock % stock2) + 1
    count = 0
    flag = False
  point = A[point-1]

print(point)


Measured memory_bytes: 32172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YahooProCon
{
    class C
    {
        static void Main(string[] args)
        {
            int[] c = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int K = c[0], A = c[1], B = c[2];

            long n=0;
            if (B > A + 2 && K >= A + 1)
            {
                n = Math.Min(A, K + 1);
                int z = K - A + 1;
                n += (long)(z / 2) * (B - A);
                if (z % 2 == 1) n++;
            }
            else
            {
                n = K + 1;
            }
            Console.WriteLine(n);
        }

    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    int ans = n % 1000 == 0 ? 0 : 1000 - n % 1000;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int sum = 0, t = n;
  while(t){
    sum += t%10;
    t /= 10;
  }
  if(n%sum==0) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005],ans=1;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	ans=1;
	for(int i=1;i<n;i++)
	{
		if(a[i]!=a[i-1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<cstring>
using namespace std;
int main()
{
   int i,c=0,n;
   cin>>n;
   string s;
   cin>>s;
   for(i=0;i<n;i++)
   {
       if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        c++;
   }
   cout<<c;
   return 0;
}


Measured memory_bytes: 3604
def main():
    N, M = map(int, input().split())
    L = []
    R = []
    for _ in range(M):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
    if min(R) - max(L) >= 0:
        print(min(R) - max(L) + 1)
    else:
        print(0)


main()


Measured memory_bytes: 10992
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long xi = sc.nextLong();
		long xo = sc.nextLong();
		long xt = sc.nextLong();
		long xj = sc.nextLong();
		long xl = sc.nextLong();
		long ans1 = 0;
		long ans2 = 0;

		ans1 += (xj/2)*2;
		ans1 += (xl/2)*2;
		ans1 += (xi/2)*2;
		ans1 += xo;

		if( xi != 0 && xj != 0 && xl != 0 ){
			ans2 += 3;
			xj--; xl--; xi--;
		}
 
		ans2 += (xj/2)*2;
		ans2 += (xl/2)*2;
		ans2 += (xi/2)*2;
		ans2 += xo;
 
		System.out.println(Math.max(ans1,ans2));
		return;
	}
}

Measured memory_bytes: 10196
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int S; cin >> S;
  set<int> ALL;
  int ans = 0;
  while (true) {
    if (!ALL.count(S)) {
      ALL.insert(S);
    } else {
      break;
    }
    ans++;
    S = (S % 2 == 0 ? S / 2 : 3 * S + 1);
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    map<char, int> mp;
    for (char c : s) {
        mp[c]++;
    }
    cout << (all_of(mp.begin(), mp.end(), [](pair<char, int> p){ return p.second % 2 == 0; }) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[200005],b[200005],c[200005];
int main()
{
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        c[a[i]]=i;
        b[i]=1;
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
            ans=max(ans,b[1]);
        }
        else if(c[a[i]]>c[a[i]-1])
        {
            b[a[i]]=b[a[i]-1]+1;
            ans=max(ans,b[a[i]]);
        }
    }
    ans=n-ans;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

int n,A,B,C;
vi l;

int dfs(int cnt, int a, int b, int c){
  if(cnt == n){
    if(a*b*c == 0) return 1e9;
    return abs(A-a) + abs(B-b) + abs(C-c) - 30;
  }

  int ret = 1e9;
  chmin(ret, dfs(cnt+1, a+l[cnt], b, c) + 10);
  chmin(ret, dfs(cnt+1, a, b+l[cnt], c) + 10);
  chmin(ret, dfs(cnt+1, a, b, c+l[cnt]) + 10);
  chmin(ret, dfs(cnt+1, a, b, c));

  return ret;
}

int main(){
  int A,B,Q; cin >> A >> B >> Q;
  vl s(A); rep(a,A) cin >> s[a];
  vl t(B); rep(b,B) cin >> t[b];
  sort(all(s)); sort(all(t));

  vl x(Q); rep(q,Q) cin >> x[q];

  rep(q,Q) {
    ll ans = INF;
    int a = lower_bound(all(s), x[q]) - s.begin();
    int b = lower_bound(all(t), x[q]) - t.begin();
    if(a < A && b < B){
      chmin(ans, abs(x[q] - s[a]) + abs(s[a] - t[b]));
      chmin(ans, abs(x[q] - t[b]) + abs(t[b] - s[a]));
    }
    if(a < A && b-1 >= 0){
      chmin(ans, abs(x[q] - s[a]) + abs(s[a] - t[b-1]));
      chmin(ans, abs(x[q] - t[b-1]) + abs(t[b-1] - s[a]));
    }
    if(a-1 >= 0 && b < B){
      chmin(ans, abs(x[q] - s[a-1]) + abs(s[a-1] - t[b]));
      chmin(ans, abs(x[q] - t[b]) + abs(t[b] - s[a-1]));
    }
    if(a-1 >= 0 && b-1 >= 0){
      chmin(ans, abs(x[q] - s[a-1]) + abs(s[a-1] - t[b-1]));
      chmin(ans, abs(x[q] - t[b-1]) + abs(t[b-1] - s[a-1]));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3712