akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp.split.to!(int[]).sum;
  writeln(s > 21 ? "bust" : "win");
}


Measured memory_bytes: 256
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,a[100],b[100],s=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<n;i++)scanf("%d",&b[i]);
  for(i=0;i<n;i++)s+=MAX(a[i]-b[i],0);
  printf("%d\n",s);
  return 0;
}
  


Measured memory_bytes: 128
#[allow(dead_code)]
fn read_line(n: usize) -> String {
    let mut ss = String::new();
    for _i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        ss.push_str(&s);
    }
    ss
}

macro_rules! parse {
    ($s:expr => $($r:tt)*) => {
        let s = $s;
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        parse!{s => $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    parse!{
        r: usize,
    }
    println!("{}", r * r);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
constexpr int P = 1'000'000'007;
int n;
std::vector<int> a, deg, ans, b;
std::set<int> s;
std::set<std::pair<int, int>> d;
std::vector<bool> used;
void dfs(int c, int lim) {
    if (c == n) {
        for (int i = 0; i < n; ++i)
            std::cout << ans[i] + 1 << " \n"[i == n - 1];
        exit(0);
    }
    for (int i = 0; i < int(b.size()); ++i) {
        if (used[b[i]] || b[i] == lim)
            continue;
        ans[c] = b[i];
        used[b[i]] = true;
        dfs(c + 1, a[b[i]]);
        used[b[i]] = false;
    }
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n;
    if (n == 2) {
        std::cout << -1 << "\n";
        return 0;
    }
    a.resize(n);
    deg.resize(n);
    ans.resize(n);
    used.resize(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
        --a[i];
        ++deg[a[i]];
    }
    for (int i = 0; i < n; ++i)
        s.insert(i);
    for (int i = 0; i < n; ++i)
        d.emplace(-deg[i], i);
    int lim = -1;
    for (int i = 0; i < n - 5; ++i) {
        int u;
        if (-d.begin() -> first == n - i - 1) {
            u = d.begin() -> second;
        } else if (*s.begin() != lim) {
            u = *s.begin();
        } else {
            u = *std::next(s.begin());
        }
        s.erase(u);
        d.erase({-deg[u], u});
        used[u] = true;
        if (!used[a[u]]) {
            d.erase({-deg[a[u]], a[u]});
            --deg[a[u]];
            d.emplace(-deg[a[u]], a[u]);
        }
        lim = a[u];
        ans[i] = u;
    }
    b.assign(s.begin(), s.end());
    dfs(std::max(0, n - 5), lim);
    std::cout << -1 << "\n";
    return 0;
}

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

#define NIL NULL
#define N 500000

struct node{
  struct node *parent;
  struct node *right;
  struct node *left;
  int key;
};

typedef struct node * Node;

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);
Node find(Node,int);

int main(void){
  int n,x;
  int i;
  char com[20];
  Node t;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf(" %s",com);
    if(com[0] == 'i'){
      scanf(" %d",&x);
      insert(x);
    }
    else if(com[0] == 'f'){
      scanf(" %d",&x);
      t = find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

void inorder(Node u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node find(Node u, int k){
  while(u != NIL && u->key != k){
    if(k < u->key){
      u = u->left;
    }
    else{
      u = u->right;
    }
  }
  return u;
}



Measured memory_bytes: 20452
x,y = map(int,input().split())
import sys
sys.setrecursionlimit(10**6)



a = (2*x-y)/3
b = (2*y-x)/3
if not (a.is_integer() and  b.is_integer()) or 2*x<y or 2*y<x:
    print(0)
    sys.exit()
    
a = int(a)
b = int(b)

from functools import reduce
def mycmb(n,r,p):
    r = min(r,n-r)
    if r == 0:
        return 1
    over = reduce(lambda x,y:x*y%p,range(n,n-r,-1))
    under = reduce(lambda x,y:x*y%p,range(1,r+1))
    return (over * pow(under,p-2,p))%p

mod = 10**9+7
print(mycmb(a+b,a,mod))


Measured memory_bytes: 9596
import math

N, K = map(int, input().split(" "))
As = list(map(int, input().split(" ")))

S = sum(As)
l = []
i = 1
ans = 1

while i*i <= S:
  if S % i == 0:
    l.append(i)
    l.append(S//i)
  i += 1

l.sort(reverse=True)

for i in l:
  ext = 0
  exts = []
  for j in As:
    exts.append(j % i)
    ext += (j % i)
  if ext % i != 0:
    continue
  else:
    p = 0
    exts.sort()
    cnt = ext//i
    for k in range(0, N - cnt):
      p += exts[k]
    if p <= K:
      ans = i
      break

print(ans)

Measured memory_bytes: 41708
#!/usr/bin/env python3

NIL: int = -1


class DFS():
    def __init__(self, n, G, debug=False):
        self.n = n
        self.G = G
        self.color = [NIL] * n

        self.debug = debug
        self._debug_print_G()
        self._debug_print_color()

    def assign_color(self):
        id = 1                  # color の id
        for u in range(self.n):
            if self.color[u] == NIL:
                self._dfs(u, id)
                id += 1
        self._debug_print_color()

    def can_reach(self, s, t) -> ():
        """boolを返すっぽいけど、yes / no を　print するメソッド"""
        if self.color[s] == self.color[t]:
            print('yes')
        else:
            print('no')

    def _dfs(self, r: int, c: int):
        S = []                  # list をスタックとして使う
        S.append(r)
        self.color[r] = c
        while len(S) > 0:
            u = S.pop()
            for v in self.G[u]:
                if self.color[v] == NIL:
                    self.color[v] = c
                    S.append(v)

    def _debug_print_G(self):
        if not self.debug:
           return
        for i in range(self.n):
            print(f'{i}: {self.G[i]}')

    def _debug_print_color(self):
        if not self.debug:
           return
        print(f'color: {self.color}')


def main():
    n, m = [int(char) for char in input().split()]

    G = [[] for _ in range(n)]  # n要素の配列の配列
    for _ in range(m):
        s, t = [int(char) for char in input().split()]
        G[s].append(t)
        G[t].append(s)
    dfs = DFS(n, G)
    dfs.assign_color()

    q = int(input())
    for _ in range(q):
        s, t = [int(char) for char in input().split()]
        dfs.can_reach(s, t)


if __name__ == '__main__':
    main()



Measured memory_bytes: 23404
import Data.Array.Unboxed
import qualified Data.ByteString as B

main = do
  n <- readLn
  input <- B.getContents
  let tab = listArray ((0,0),(n-1,n-1)) $ map fromEnum $ B.unpack $ B.filter (20<) $ input
  print (solve n tab)

type Table = UArray (Int,Int) Int

isGood :: Int -> Int -> Table -> Bool
isGood n dx tab =
  and [tab!(f x,y) == tab!(f y,x) | x<-[0..n-1], y<-[x..n-1]]
  where
    f i = (i+dx)`mod`n

solve :: Int -> Table -> Int
solve n tab =
  n * length [() | i<-[0..n-1], isGood n i tab]

Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int h,w;
  vector<int> g[30];
  char s,t,a[50][50];
  cin>>h>>w>>s>>t;  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if('A'>=a[i][j]||a[i][j]>='Z')continue;
      
      int dx[4]={0,1,0,-1};
      int dy[4]={1,0,-1,0};
      for(int k=0;k<4;k++){
	int tx=i+dx[k],ty=j+dy[k];
	while(1){
	  if(tx<0||h<=tx||ty<0||w<=ty)break;
	  if(a[tx][ty]=='.')break;
	  if(k%2&&a[tx][ty]=='-')break;
	  if(k%2==0&&a[tx][ty]=='|')break;
	  if('A'<=a[tx][ty]&&a[tx][ty]<='Z'){
	    g[a[i][j]-'A'].pb(a[tx][ty]-'A');
	    g[a[tx][ty]-'A'].pb(a[i][j]-'A');
	    break;
	  }
	  tx+=dx[k],ty+=dy[k];
	}
      }
    }
  }

  queue<P>q;
  q.push(P(s-'A',0));
  int used[30]={};

  while(q.size()){
    int node=q.front().fi;
    int l=q.front().se;
    q.pop();
    if(node==t-'A'){
      cout<<l<<endl;
      return 0;
    }
    if(used[node])continue;
    used[node]=1;
    for(int i=0;i<g[node].size();i++){
      q.push(P(g[node][i],l+1));
    }
  }
  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll s(n); REP(i, n) cin >> s.at(i);
  ll res = 0;
  rep(p, 1, n) {
    if ((n-1) % p == 0) {
      ll tmp = 0, cur = 0;
      ll i = 0, j = n-1;
      for (; i<j; i+=p, j-=p) {
        cur += s.at(i) + s.at(j);
        tmp = max(tmp, cur);
      }
      res = max(res, tmp);
    } else {
      ll tmp = 0, cur = 0;
      ll i = 0, j = n-1;
      for (; i<n-1&&j>p; i+=p, j-=p) {
        cur += s.at(i) + s.at(j);
        tmp = max(tmp, cur);
      }
      res = max(res, tmp);
    }
  }
  cout << res << endl;
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  double X;
  vector<int> value(N);
  for(int i=0;i<N;i++)
    cin>>value.at(i);
  sort(value.begin(),value.end());
  for(int i=0;i<N;i++){
    if(i!=0)
      X=(X+(double)value.at(i))/2;
    else
      X=value.at(0);
  }
  cout<<X<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  set<int> st;
  rep(i, n-1) {
    if(s[i] == 'R' && s[i+1] == 'L') {
      st.insert(i);
    }
  }
  vector<int> ans(n);
  rep(i, n) {
    int j;
    if(s[i] == 'R') {
      j = *st.lower_bound(i);
    } else {
      j = *(--st.upper_bound(i));
    }
    if(abs(j-i)%2==0) ans[j]++;
    else ans[j+1]++;
  }
  rep(i, n) cout << ans[i] << ' ';
  cout << endk;
  return 0;
}


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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll a, b;
  cin >> a >> b;

  cout << a * b << endl;

  return 0;
}

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

int n;
vector<int> a;
long long ans;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	a.resize(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	long long sum = 0, res = 0;
	for(int i = 0; i < n; i++) {
		if(i%2 && sum+a[i] >= 0) res += sum+a[i]+1, sum = -1;
		else if(!(i%2) && sum+a[i] <= 0) res += 1-(sum+a[i]), sum = 1;
		else sum += a[i];
	}
	ans = res;
	sum = 0, res = 0;
	for(int i = 0; i < n; i++) {
		if(!(i%2) && sum+a[i] >= 0) res += sum+a[i]+1, sum = -1;
		else if(i%2 && sum+a[i] <= 0) res += 1-(sum+a[i]), sum = 1;
		else sum += a[i];
	}
	ans = min(res, ans);
	cout << ans;
}


Measured memory_bytes: 640
def solve(a, b):
    a.sort()
    b.sort()
    d = sum(a) - sum(b)
    if d % 2 != 0:
        return -1
    for x in a:
        for y in b:
            if x - y == d/2:
                return " ".join(map(str,[x, y]))
            if x - y <  d/2:
                break
    return -1

while True:
    n, m = map(int, raw_input().split())
    if n == 0 and m == 0:
        break
    s = [int(raw_input()) for _ in range(n+m)]
    #print s[:n], s[n:], sum(s[:n]), sum(s[n:])
    print solve(s[:n], s[n:])


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  bool even = true;
  for (auto &it : A)
    if (it % 2 != 0)
      even = false;
  if (even)
    cout << "second" << endl;
  else
    cout << "first" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;

struct Edge {
  ll to;
  ll cost;
};

using Graph = vector<vector<Edge>>;

void dfs(const Graph &G, ll v, ll p, ll sum, vector<ll> &dist) {
  dist[v] = sum;
  for (auto e : G[v]) {
    if (e.to == p) continue;
    dfs(G, e.to, v, sum + e.cost, dist);
  }
}

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

  vector<vector<Edge>> G(N);

  REP(i, N - 1) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    G[a].push_back(Edge{b, c});
    G[b].push_back(Edge{a, c});
  }
  ll Q, K;
  cin >> Q >> K;
  K--;

  vector<ll> dist(N, 0);
  dfs(G, K, -1, 0, dist);

  REP(q, Q) {
    ll x, y;
    cin >> x >> y;
    x--, y--;

    cout << dist[x] + dist[y] << endl;
  }

  return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  string s;
 
  // 変数aで入力を受け取る
  cin >> a;
  cin >> s;

  if(a>=3200){
	cout << s << endl;
  }else{
 	cout << "red" << endl;   
  
  }
}

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

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

    int h, w;
    cin >> h >> w;

    char C[h][w];
    REP(i, h) REP(j, w) cin >> C[i][j];

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

    REP(i, h){
        REP(j, w){
            if(C[i][j] == '#'){
                bool f = true;
                REP(k, 4){
                    int nx, ny;
                    nx = i + dx[k];
                    ny = j + dy[k];
                    if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                        continue;
                    }
                    if(C[nx][ny] == '#'){
                        f = false;
                        break;
                    }
                }
                if(f){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	void A() {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(Math.max(0,(H-h)*(W-w)));
	}
	void B() {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int ans = 0;
		int []  B = new int[M];
		int [] A = new int[M];
		for(int i = 0; i < M; i++) B[i] = sc.nextInt();
		for(int i = 0; i < N; i++) {
			int tmp = C;
			for(int j = 0; j < M; j++) {
				A[j] = sc.nextInt();
				tmp += A[j] * B[j];
			}
			if(tmp>0) ans++;
		}
		System.out.println(ans);
	}
	void C() {
		int N = sc.nextInt();
		long M = sc.nextLong();
		Pair [] data = new Pair[N];
		for(int i = 0; i < N; i++) {
			long a = sc.nextLong(), b = sc.nextLong();
			data[i] = new Pair(a,b);
		}
		Arrays.sort(data);
		long ans = 0;
		for(int i = 0; i < N; i++) {
			if((int)data[i].b <= M) {
				ans  += data[i].a * data[i].b;
			} else {
				ans += (long) M * data[i].a;
			}
			M -= data[i].b;
			//System.out.println(ans + " " + data[i].a + " " + data[i].b + " " + M);
			if(M <=0) break;
		}
		System.out.println(ans);
	}
	class Pair implements Comparable<Pair>{
		long a, b;
		Pair(long a, long b) {
			this.a = a; this.b = b;
		}
		public int compareTo(Pair other) {
			if(this.a < other.a) return -1;
			if(this.a > other.a) return +1;
			if(this.b < other.b) return -1;
			if(this.b > other.b)return +1;
			return 0;
		}
	}
	long Df(long a, int bit) {
		a++;
		long b = 1L << bit;
		long c = b * 2L;
		long ans = a / c * b;
		ans += Math.max(a % c - b, 0L);
		//System.out.println(a + ":" + bit + " " + b + " " + c + " " + ans);
		return ans;
	}
	void D() {
		long A = sc.nextLong();
		long B = sc.nextLong();
		long ans = 0;
		
		for(int i = 0; i < 50; i++) {
			long a1 = Df(A-1L, i);
			long b1 = Df(B, i);
			if((b1-a1) % 2L != 0L) {
				ans += (1L << i);
			}
			//System.out.println(i + " " + (1L<<i) + " " + a1 + " " + b1 + " " + ans);
		}
		System.out.println(ans);
	}
	void doIt() {
		D();
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}


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

int main() {
    string s;
    int a=0, b=0;
    cin >> s;

    for (int i = 0; i < s.length(); i++)
    {
        if(s[i]=='A') 
        {
            a = i;
            break;
        }
    }
   
    for (int i = 0; i < s.length(); i++)
    {
        if(s[i]=='Z') b = max(b, i);
    }

    cout << b-a+1 << endl;  
    return 0;
}

Measured memory_bytes: 3728
n = int(input())
*A, = map(int, input().split())
# n = 4
# A = [10, 20, 30, 40]
inf = 10**20
DP = [[None for r in range(n+1)] for l in range(n)]
S = [0]
for i in range(n):
    S.append(S[-1]+A[i])


def f(l, r):
    if r <= l+1:
        DP[l][r] = 0
    if DP[l][r] != None:
        return DP[l][r]
    DP[l][r] = S[r]-S[l]+min([f(l, i)+f(i, r) for i in range(l+1, r)])
    return DP[l][r]


print(f(0, n))


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

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

using namespace std;


int main(){
    int n, l, t;
    cin >> n >> l >> t;
    vector<int> x(n), w(n);
    rep(i, n) cin >> x[i] >> w[i];
    
    ll cnt = 0;
    rep(i, n){
        if(w[i] == 1) x[i] += t;
        else          x[i] -= t;

        cnt += x[i] / l;
        x[i] %= l;
        if(x[i] < 0){
            x[i] += l;
            cnt--;
        }
    }
    sort(x.begin(), x.end());

    cnt = (cnt%n+n)%n;
    rep(i, n) cout << x[(i+cnt)%n] << endl;

    return 0;
}


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

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  int a, b;
  cin >> a >> b;

  bool hakken = false;
  for (int i = 1; i < 2000; i++) {
    if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      cout << i << endl;
      hakken = true;
      break;
    }
  }
  if (!hakken) cout << "-1" << endl;
}


Measured memory_bytes: 384
n = int(input())
house = []
for i in range(4):
    house.append([])
    for j in range(3):
        house[i].append([])
        for k in range(10):
            house[i][j].append(0)

for i in range(n):
    b,f,r,v = map(int,input().split())
    house[b-1][f-1][r-1] += v


for i in range(4):
    for j in range(3):
        for k in range(10):
            print("" , house[i][j][k], end="")
        print()
    if i < 3:
        print("#" * 20)

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

using namespace std;
int n;
int peso[1000];
long long int valor[1000];
long long int dp[100][100001];
int calculado[100][100001];
long long int solve(int ind, int aguenta){
	if(ind == n && aguenta >= 0){
		return 0LL;
	}
	if(calculado[ind][aguenta] == true){
		return dp[ind][aguenta];
	}
	long long int ans = solve(ind+1,aguenta);
	if(peso[ind] <= aguenta){
		ans = max(ans,valor[ind] + solve(ind + 1, aguenta - peso[ind]));
	}
	calculado[ind][aguenta] = true;
	dp[ind][aguenta] = ans;
	return ans;
}
int main(){
	int k;
	cin >> n >> k;
	memset(calculado,0,sizeof calculado);
	for(int i = 0 ; i < n ;i++){
		cin >> peso[i] >> valor[i];
	}
	cout << solve(0,k) << endl;
	return 0;
}


Measured memory_bytes: 117504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int k;
mint ans;
vector<int> to[100005];
void dfs(int v,int p = -1){
    // cout << v << endl;
    int num_child = to[v].size();
    if(p!=-1){
        num_child--;
        rep(i,num_child){
            ans *= (k-i-2);
        }
    }else{
        ans *= k;
        rep(i,num_child){
            ans *= (k-i-1);
        }
    }
    for(int u:to[v]){
        if(u==p)continue;
        dfs(u,v);
    }    
}

int main(){
    int n;
    cin >> n >> k;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans = 1;
    dfs(0);
    cout << ans.x << endl;
}

Measured memory_bytes: 9216
#include <stdio.h>
#include <string.h>
char s[100050];
int main(void)
{
	fgets(s,100050,stdin);
	int len=strlen(s),flag=1;
	char *p=s,*q=s+len-2;
	while (p<=q && flag)
	{
		if (*q=='b')
		{
			if (*p!='d') flag=0;
		}
		else if (*q=='d')
		{
			if (*p!='b') flag=0;
		}
		else if (*q=='p')
		{
			if (*p!='q') flag=0;
		}
		else if (*q=='q')
		{
			if (*p!='p') flag=0;
		}
		else
		{
			if (*p!=*q) flag=0;
		}
		p++;
		q--;
	}
	puts(flag ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1ll << 59;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


void dfs(vvpl &tree, vll &cost, int curr = 0) {
	rep(i, tree[curr].size()) {
		int next = tree[curr][i].first;
		ll cos = tree[curr][i].second;
		if (cost[next] != -1) continue;
		cost[next] = cost[curr] + cos;
		dfs(tree, cost, next);
	}
}

int main()
{
	int N;
	cin >> N;
	vvpl tree(N);
	rep(i, N - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		tree[a].push_back(mp(b, c));
		tree[b].push_back(mp(a, c));
	}

	int Q, K;
	cin >> Q >> K;
	K--;

	vll cost(N, -1);
	cost[K] = 0;
	dfs(tree, cost, K);

	rep(i, Q) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cout << cost[x] + cost[y] << endl;
	}


	return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>
int main(void)
{
	int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r );
    if((x + r <= w && x - r >= 0) && (y + r <= h && y - r >= 0))
{
		printf("Yes\n");
}
	else
{
		printf("No\n");
}
	return 0;
}


Measured memory_bytes: 2692
#include <stdio.h>

int main(void)
{
	int n,d;
	int mi,co;
	int c_num;
	int a[50][20];
	int dummy;
	int ansx,ansy;
	char c[100][20];

	scanf("%d", &n);
	while(n != 0){
		for(int i = 1; i <= n; i++){
			a[0][i] = i;
		}
		scanf("%d", &mi);
		scanf("%d", &co);
		scanf("%d", &d);

		for(int i = 0; i < d; i++){
			scanf("%s", &c[i]);
			for(int j = 1; j <= n; j++){
				a[i + 1][j] = a[i][j];
			}
			for(int j = 0; j < n - 1; j++){
				if(c[i][j] == '1'){
					dummy = a[i + 1][j + 1];
					a[i + 1][j + 1] = a[i + 1][j + 2];
					a[i + 1][j + 2] = dummy;
				}
			}
			for(int j = 1; j <= n; j++){
				//printf("%d ",a[i + 1][j]);
			}
			//printf("\n");
		}
		c_num = a[d][co];
		//printf("%d\n",c_num);

		ansx = 0;
		ansy = 0;

		if(c_num == mi){
			printf("0\n");
		}else{
			for(int i = d - 1; i >= 0; i--){
				for(int j = 1; j <= n - 1; j++){
					if(((a[i][j] == mi && a[i][j + 1] == c_num) || (a[i][j + 1] == mi && a[i][j] == c_num)) &&c[i][j - 2] != '1' && c[i][j - 1] != '1' && c[i][j] != '1'){
						ansy = i + 1;
						ansx = j;
					}
				}
			}
			if(ansy != 0 && ansx != 0){
				printf("%d %d\n",ansy,ansx);
			}else{
				printf("1\n");
			}
		}
		scanf("%d", &n);
	}
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N, M;
  cin >> N >> M;

  vector<vector<int>> A(N,vector<int>(M,0));
  REP(i, N){
    int K;
    cin >> K;
    REP(j, K){
      cin >> A.at(i).at(j);
    }
  }
  int flag = 0;
  int flag2 = 0;
  int cnt = 0;
  FOR(i,1,M+1){
    flag2 = 0;
    REP(j,N){
      flag = 0;
      REP(k,M){
        if(A.at(j).at(k)==i){
          flag = 1;
        }
      }
      if(flag == 0){
        flag2 = 1;
      }
    }
    if(flag2 == 0){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
def a_limited_insertion(N, B):
    """
    空の数列Aに対し、
    ・i回目の操作では i<=j<=iを満たす整数jを選び、Aの先頭からj番目にjを挿入する
    という操作をN回行う。その後A, Bが一致することがあるか判定し、あるなら
    それを達成する操作手順を1つ示せ。
    """

    # この問題を言い換える。
    # 「数列Bに対し、左からk番目(1-based)の要素がkであるならば、
    # それを取り除くことができる。数列Bを空にできるか？」
    # このとき、取り除ける要素のうち、最も右側にあるものを選ぶほかない。
    # なぜなら、そうでないものを取り除くと、二度と取り除くことができない要素が
    # 生じるからである。
    # e.g. B: * * 3 * * 6 に対して3を取り除くと、6が取り除けなくなる
    # これをシミュレートすれば、O(N**2)時間で判定できる。
    ans = []
    while B:
        for k in range(len(B) - 1, -1, -1):
            if B[k] == k + 1:
                ans.append(k + 1)
                B.pop(k)
                break
        else:
            return -1
    # 逆操作での解を得たので、それを反転させると元の操作での解になる
    return ' '.join(map(str, reversed(ans)))

N = int(input())
B = [int(i) for i in input().split()]
print(a_limited_insertion(N, B))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005

int main(){

    int n,m;
    while(cin >> n >> m,n){

        int a[n],b[m];
        int sum_a = 0,sum_b = 0;
        int mini_i,mini_j;//交換する組み
        int mini = INF;//交換する組みの和の最小

        REP(i,n){
            cin >> a[i];
            sum_a += a[i];
        }
        REP(i,m){
            cin >> b[i];
            sum_b += b[i];
        }

        int diff_a = INF,diff_b = INF;//交換したことによる総和の変化
        int sum_a_after,sum_b_after;
        bool exist = false;
        REP(i,n){
            REP(j,m){
                //a[i]とb[m]を交換する
                sum_a_after = sum_a + b[j] - a[i];
                sum_b_after = sum_b + a[i] - b[j];
                if(sum_a_after == sum_b_after && a[i] + b[j] < mini){
                    diff_a = a[i];
                    diff_b = b[j];
                    mini = a[i] + b[j];
                    exist = true;
                }
            }
        }
        if(exist){
            cout << diff_a << " " << diff_b << endl;
        }else{
            cout << "-1" << endl;
        }
    }


    return 0;
}


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

int a,b,c; 

int main(){

    cin>>a>>b>>c;
    int M,m;
    cout<<abs(a-b)+abs(a-c)+abs(b-c)-max(abs(a-b),max(abs(a-c),abs(b-c)))<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define inf 0x3f3f3f3f

using namespace std;

int paths[210][210];
int R[210];
int n,m,r;

void floyd()
{
    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
               paths[i][j]=min(paths[i][k]+paths[k][j],paths[i][j]);//更新i到j的最短距离
            }
        }
    }
}

int main()
{
    while(scanf("%d%d%d",&n,&m,&r)==3)
    {
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
            {
                if(i==j)paths[i][j]=0;
                else paths[i][j]=inf;
            }
        }
        for(int i=0;i<r;i++)
        {
            scanf("%d",&R[i]);
        }
        int a,b,c;
        for(int i=1;i<=m;i++)
        {
            scanf("%d%d%d",&a,&b,&c);
            if(paths[a][b]>c||paths[b][a]>c)
            {
                paths[a][b]=paths[b][a]=c;
            }
        }
        floyd();
        sort(R,R+r);
        int ans=inf;
        do
        {
            int sum=0;
            for(int i=0;i<r-1;i++)
            {
                sum+=paths[R[i]][R[i+1]];//计算总路程
            }
            ans=min(ans,sum);//更新最短总路程
        }while(next_permutation(R,R+r));//枚举经过的点的顺序
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  int s[1000];
  cin >> n >> k;
  int i=0;
  while(n>0){
    s[i]=n%k;
    n/=k;
    i++;
  }
  cout << i << endl;
}
    
    
    
   

Measured memory_bytes: 256
function main()
  
  N = parse(Int,readline())
  S = split(chomp(readline()),"")
  
  ans = 0
  
  for i in 1:N
    
    x = Set(S[1:i])
    y = Set(S[i+1:end])
    
    moji = length(x) + length(y) - length(union(x,y))
    
    ans = max(ans,moji)
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 121916
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;

	ll now = 1;
	ll num = 1e18;

	vector<ll> a(n);
	for(int i = 0;i < n;i++)cin >> a[i];
	for(int i = 0;i < n;i++){
		if(a[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	bool flag = false;
	for(int i = 0;i < n;i++){
		if(num % now == 0){
			if(num / now < a[i]){
				flag = true;
			}
		}
		if(num % now != 0){
			if((num+now-1)/now <= a[i]){
				flag = true;
			}
		}

		if(!flag)now *= a[i];
	}

	if(flag)cout << -1 << endl;
	else cout << now << endl;
}


Measured memory_bytes: 4052
import java.util.*;
import java.math.BigInteger;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      int a = scan.nextInt() ;
      int b =scan.nextInt() ;
      int t = n/(a+b) ; 
      if(n < t*(a+b)+b){
          System.out.println(t-1);
      }else{
          System.out.println(t);
      }
      }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int powint(int a, int x){
	int res = 1;
	REP(i,x){
		res = res *a; 
	}
	return res;
}

using namespace std;

int main(){
	int N;
	cin>>N;
	vector<int> d(N);
	REP(i,N){
		cin>>d[i];
	}
	sort(d.begin(),d.end());
	int ans=1;
	REP(i,N-1){
		if(d[i]!=d[i+1]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> v;
int N, M;
int ans = 0;
int amari = INF2;
bool isOK(int num) {
    int cnt = 0;
    int sum = 0;
    rep(i, N) {
        auto itr = lower_bound(v.begin(), v.end(), num - v[i]);
        auto pos = distance(v.begin(), itr);
        //cout << v[i] << " " << pos << endl;
        cnt += N - pos;
        sum += (N - pos) * v[i] * 2;
    }
    if (cnt <= M) {
        ans = max(ans, sum);
        amari = min(amari, M - cnt);
    }
    //cout << "*" <<  cnt << endl;
    return cnt <= M;
}

// 汎用的な二分探索のテンプレ
int binary_search() {
    int ng = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = INF2; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, N) {
        int A; cin >> A;
        v.push_back(A);
    }
    sort(v.begin(), v.end());
    /*
    while(true) {
        int num;
        cin >> num;
        isOK(num);
    }
    //*/
    int add = binary_search() - 1;
    //cout << binary_search()<< " " << amari << endl;
    cout << ans  + add * amari << endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	
	int ans = 0;
	vector<int> arr(n);
	arr[0] = s[0] == 'L';
	for(int i = 1; i < n; i++) {
		if(s[i] == s[i-1]) {
			ans++;
		}
		arr[i] = s[i] == 'L';
		
	}
	
	arr.resize(unique(arr.begin(), arr.end()) - arr.begin());
	int sz = arr.size();
	for(int i = 1; i < sz; i++) {
		if(i < sz-1 && arr[i] != arr[i-1] && arr[i] != arr[i+1] && k > 0) {
			ans += 2;
			arr[i] ^= 1;
			k--;
		} else if(i == sz-1 && arr[i] != arr[i-1] && k > 0) {
			ans++;
			k--;
		}
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 848
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    while(cin>>n){
        ll ans,x;
        ans=n/11<<1;
        x=n%11;
        if(x>6)
            ans+=2;
        else if(x)
            ans++;
        cout<<ans<<endl;
    }
    return 0;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)

#define lli long long
#define li long
#define vi vector<int>
#define vli vector<li>
#define vlli viector<lli>
#define pi pair<int,int>
#define vpi vector<pi>

using namespace std;

int main() {
    int a, b;

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

    if(a > 12) cout << b << endl;
    else if(a >= 6) cout << b / 2 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")



int main() {

    ll n; cin >> n;
    ll d = 10;
    ll ans = 0;

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

    while(d <= n){
        ans += n/d;
        d *= 5;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main () {
   int d, n; cin >> d >> n;

   int ans;
   if(d == 0) {
      ans = n;
   } else if(d == 1){
      ans = 100*n;
   } else {
      ans = 10000*n;
   }

   if(n == 100) {
      if(d == 0) {
         ans = n + 1;
      } else if(d == 1) {
         ans = 100*n + 100;
      } else {
         ans = 10000*n + 10000;
      }
   }

   cout << ans << endl;
}

Measured memory_bytes: 3592
import math
a,b,h,m=map(int,input().split())
res=min(abs(h*30+m/2-m*6),abs(h*30+m/2-m*6-360))
ans=a**2+b**2-2*a*b*math.cos(res*math.pi/180)
print(math.sqrt(ans))

Measured memory_bytes: 62580
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("")
#define pair pair<LL,LL>
#define space putchar(' ')
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
template <typename tp> inline void read(tp & x)
{  
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); }
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    x*=f;
}  
     
template <typename Tp> inline void print(Tp x)
{      
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}	

int n;
char s[1000005];
int ans;
int temp;

int main()
{
	read(n);
	scanf("%s",s+1);
	for(RI i=1;i<=n;++i)
	{
		if(s[i]=='I')
			temp++,ans=max(temp,ans);
		else if(s[i]=='D')
			temp--;
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 3e5 + 5;

struct State {
  int pc, sl, sv;

  State (int _pc, int _sl, int _sv) :
    pc(_pc), sl(_sl), sv(_sv) {}
};

ostream& operator<< (ostream &out, State s) {
  out << "(" << s.pc << " " << s.sl << " " << s.sv << ")";
  return out;
}

State nxt (State s, int c) {
  if (s.pc == 2) return s;

  if (s.sl == 0) {
    if (c == 0) return State(s.pc, s.sl + 1, 0);
    if (c == 1) return State(s.pc + 1, 0, 0);
  }

  if (s.sl == 1) {
    return State(s.pc, s.sl + 1, 2 * s.sv + c);
  }

  if (c == 0) {
    if (s.sv == 0) {
      return State(s.pc, 1, 0);
    } else {
      return State(s.pc, 1, 0);
    }
  } else {
    if (s.sv == 0) {
      return State(s.pc, 1, 0);
    } else {
      return State(s.pc + 1, 0, 0);
    }
  }
};

Modint _dp [MAX_N][3][3][4];

Modint& dp (int i, State s) {
  return _dp[i][s.pc][s.sl][s.sv];
}

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

  int n = s.size();
  
  vector<State> alls;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 4; k++) {
        alls.push_back(State(i, j, k));
      }
    }
  }

  dp(0, State(0, 0, 0)) = Modint(1);
  for (int i = 0; i < n; i++) {
    for (State st : alls) {
      if (s[i] != '1') {
        dp(i + 1, nxt(st, 0)) += dp(i, st);
      }
      if (s[i] != '0') {
        dp(i + 1, nxt(st, 1)) += dp(i, st);
      }
    }
  }

  Modint ans (0);
  ans += dp(n, State(2, 0, 0));
  ans += dp(n, State(1, 2, 1));
  ans += dp(n, State(1, 0, 0));
  cout << ans << endl;
}


Measured memory_bytes: 85252
#include<stdio.h>
int main(void){
int D,G,res=1<<30;
  scanf("%d %d",&D,&G);
  int p[D],c[D];
  for(int i=0;i<D;i++){
    scanf("%d %d",&p[i],&c[i]);
  }
int i,j;
  for(i=0;i<(1<<D);i++){
    int sum=0;
    int cnt=0;
   // printf("%dパターン目\n",i+1);
    for(j=0;j<D;j++){
      
      if(i&(1<<j)){
        sum+=100*(j+1)*p[j]+c[j];    //そのパターンにおける合計スコア
        cnt+=p[j];					//そのパターンにおける解いた問題数
      }
    }
      if(sum>=G){
        if(res>cnt)res=cnt;    //最小値の更新
      }
      else{
        for(int j=D-1;j>=0;j--){//高得点問題から優先的に解く
          
          if(i&(1<<j)) continue;//全完済みの問題をスキップ
          for(int k=0;k<p[j];k++){
            if(sum>=G)break;
          sum+=100*(j+1);
          cnt++;
          }
        }
        
       if(res>cnt)res=cnt;
      }
    
    
  }
    printf("%d",res);
  }
  

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			char[] c=sc.next().toCharArray();
			if(c[0]==c[1]&&c[1]==c[2]&&c[0]!='s'){
				System.out.println(c[0]);
			}else if(c[3]==c[4]&&c[4]==c[5]&&c[3]!='s'){
				System.out.println(c[3]);
			}else if(c[6]==c[7]&&c[7]==c[8]&&c[6]!='s'){
				System.out.println(c[6]);
			}else if(c[0]==c[3]&&c[3]==c[6]&&c[0]!='s'){
				System.out.println(c[0]);
			}else if(c[1]==c[4]&&c[4]==c[7]&&c[1]!='s'){
				System.out.println(c[1]);
			}else if(c[2]==c[5]&&c[5]==c[8]&&c[2]!='s'){
				System.out.println(c[2]);
			}else if(c[0]==c[4]&&c[4]==c[8]&&c[0]!='s'){
				System.out.println(c[0]);
			}else if(c[2]==c[4]&&c[4]==c[6]&&c[2]!='s'){
				System.out.println(c[2]);
			}else{
				System.out.println("d");
			}
		}
	}
}

Measured memory_bytes: 17120
//---------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                        NEVER  GIVE  UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	string s,t;
	cin>>s>>t;
	int minn = (int)t.size();
	for(int i=0;i<(int)s.size()-(int)t.size()+1;i++) {
		int cnt = 0;
		for(int j=0;j<(int)t.size();j++) {
			if(s[i+j] != t[j])
				cnt++;
		}
		minn = min(minn, cnt);
	}
	cout<<minn;
	return 0;
}


Measured memory_bytes: 3648