akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = S.size();
    int rn = 0;
    int bn = 0;
    for(int i = 0; i < N; ++i){
        if(S[i] == '0') rn++;
        else if(S[i] == '1') bn++;
    }
    printf("%d", 2*min(rn, bn));
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{   
	    Scanner sc = new Scanner(System.in);
	    int x = sc.nextInt();
	    if(x==3 || x==5 || x==7){
	        System.out.println("YES");
	    }
	    else{
	        System.out.println("NO");
	    }
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
 
int n;
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	int ret = 0;
	FOR(i, n) {
		int l, r;
		cin >> l >> r;
		ret += (r-l+1);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var pay = new List<long>();
            pay.Add(1);
            for (var i = 6; i <= N; i *= 6)
                pay.Add(i);
            for (var i = 9; i <= N; i *= 9)
                pay.Add(i);
            pay.Sort();

            var ans = 0L;
            var dp = new long[N + 1];

            for (var i = 1; i <= N; ++i)
            {
                var min = long.MaxValue;
                foreach (var p in pay)
                {
                    if (0 <= i - p)
                        min = Min(min, dp[i - p]);
                }
                dp[i] = min + 1;
            }
            WriteLine(dp[N]);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13664
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

ll f[100005];

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll n, k;
    cin >> n >> k;

    rrep(x, k, 1){
        f[x] = power(k/x, n);
        for(int y = 2*x; y <= k; y += x) 
            f[x] = (f[x] - f[y] + MOD) % MOD;
    }

    ll res = 0;
    repp(i, 1, k) res = (res + i*f[i]) % MOD;
    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 4344
# B
N = int(input())
D_dict = dict()
D_list = list(map(int, input().split()))
M = int(input())
T_list = list(map(int, input().split()))

for i in range(N):
    di = D_list[i]
    if di not in D_dict.keys():
        D_dict[di] = 1
    else:
        D_dict[di] += 1
        

res = 'YES'
for i in range(M):
    ti = T_list[i]
    if ti not in D_dict.keys():
        res = 'NO'
    elif D_dict[ti] <= 0:
        res = 'NO'
    else:
        D_dict[ti] -= 1

print(res)

Measured memory_bytes: 41316
<?php
# 整数の入力
fscanf(STDIN, "%d %d", $n, $x);
# スペース区切りの整数の入力
$tmp = fgets(STDIN);
$l = explode(" ", $tmp);

$total = 0;
$bound = 1;
for($i=0; $i<$n; $i++){
  $total += $l[$i];
  if($total<=$x){
    $bound++;
  }
}

echo $bound."\n";

?>

Measured memory_bytes: 3828
# https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_4_B
# 仕組みは単純ゆえに、本では解説がバッサリ省略されている。操作の可視化を行うと図のようになる。
# ここでは隣接リストを用いて実装する。

from collections import deque
# 隣接リストはdefaultdictで管理すると楽です。
from collections import defaultdict
adj = defaultdict(lambda: [])

# input data
n_V, n_E = list(map(int, input().split()))
indeg = [0] * n_V  # 流入量管理
for _ in range(n_E):
    s, t = list(map(int, input().split()))
    indeg[t] += 1  # 流入量更新
    adj[s].append(t)


# Topological Sort by BFS
def topological_sort(dag, indeg):
    '''
    dag ... default dictで定義された隣接リスト(DAGを想定)
    indeg ... 各ノードについての流入量のリスト(inputのときについでにやったほうが計算量若干少なく済むでしょ？本質じゃないけど)
    '''
    is_visited = [False] * len(indeg)  # 訪問間利用
    ret = []  # グラフをソートしたあとに返す答え
    perm = [-1] * len(indeg)  # できる処理を一気にしようとしたときの順番

    que = deque()  # 各要素はノード, 処理回数
    for i, deg in enumerate(indeg):
        if deg == 0:
            que.append((i, 0))
            is_visited[i] = True

    while que:
        u, cnt = que.popleft()  # uは流入量0のノード
        ret.append(u)  # なので答えに加えていく
        perm[u] = cnt
        for to in dag[u]:  # uに隣接するノードtoについて深さ優先探索
            indeg[to] -= 1  # 隣接するノードは流入量を減らす
            if indeg[to] or is_visited[to]:
                continue  # 流入待ちか訪問済みだったら飛ばす
            que.append((to, cnt + 1))  # 次の訪問候補に追加
            is_visited[to] = True

    if False in is_visited:
        print(is_visited)
        raise ValueError('inputted graph is not DAG')

    return ret, perm


ans, _ = topological_sort(adj, indeg)
print(*ans, sep='\n')



Measured memory_bytes: 10016
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let line = readInts()
    let count = line[0]
    let amount = line[1]
    for a in 0...count {
        for b in 0...(count - a)  {
            if (a * 10000) + (b * 5000) + ((count - a - b) * 1000) == amount {
                print("\(a) \(b) \(count - a - b)")
                return
            }
        }
    }
    print("-1 -1 -1")
}

main()


Measured memory_bytes: 8152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  
  int A , B ;
  cin >> A >> B ;
  int ans = 0 ;
  rep(i,2){
    if( A >= B ){
      ans += A ;
      A--;
    }
    else{
      ans += B ; 
      B--;
    } 
  }
  cout << ans << endl;
}
  
  

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int remainder (int large, int small) {

    // cout << "remainder mode" << endl;

    if (small == 0) {
        return large;
    }

    int x, y;

    x = small;
    y = large % small;

    int answer = remainder (x, y);

    // cout << "ERROR" << endl;

    return answer;

}

int main () {

    int x, y;

    cin >> x >> y;

    int answer = remainder (x, y);

    // for (int i = max(x, y); i >= 0; i--) {
    //     // cout << i << ": " << y % i << " " << z % i << endl; 
    //     if (x % i == 0 && y % i == 0) {
    //         d = i;
    //         break;
    //     } 
    // }

    cout << answer << endl;

    return 0;

}


Measured memory_bytes: 3096
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=2*atan2(d-b,c-a);s,t=sin(g),cos(g);x-=a;y-=b
 print(f'{t*x+s*y+a:.6f} {s*x-t*y+b:.6f}')


Measured memory_bytes: 5756
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.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>;
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 f(int a){
  int ans = 0;
  while (a%2==0){
    a >>= 1;
    ++ans;
  }
  return ans;
}

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

  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int t = f(a[0]);
  rep(i,n){
    int ti = f(a[i]);
    if (ti < 1 || t != ti){
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t;
  }
  m >>= t - 1;

  ll p = 1;
  rep(i,n) {
    p = lcm(p,a[i]);
    if (p>m){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << (m/p+1)/2 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool is_prime(long long _Num){
    if(_Num < 2)return false;
    if(_Num % 2 == 0){
        if(_Num == 2)return true;
        else return false;
    }
    bool prime = true;
    for(long long i = 3; i <= sqrt(_Num); i += 2){
        if(_Num % i == 0){
            prime = false;
            break;
        }
    }
    return prime;
}

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

	vector<ll> v1 = divisor(a);
	vector<ll> v2 = divisor(b);

	map<ll, int> mp;
	rep (i, v1.size()) mp[v1[i]]++;
	rep (i, v2.size()) mp[v2[i]]++;

	vector<ll> kou;
	for (auto x: mp) if (x.se == 2 && (is_prime(x.fi) || x.fi == 1)) kou.pb(x.fi);

	cout << kou.size() << endl;
	return 0;
}

Measured memory_bytes: 768
# frozen_string_literal: true

n = gets.to_i
happies = Array.new(n) { gets.split.map(&:to_i) }

sum = Array.new(n + 1) { Array.new(3, 0) }

(0..n - 1).each do |i|
  sum[i + 1][0] = [sum[i][1] + happies[i][0], sum[i][2] + happies[i][0]].max
  sum[i + 1][1] = [sum[i][0] + happies[i][1], sum[i][2] + happies[i][1]].max
  sum[i + 1][2] = [sum[i][0] + happies[i][2], sum[i][1] + happies[i][2]].max
end

puts sum.last.max


Measured memory_bytes: 16124
#include<cstdio>
#include<iostream>
#include<queue>
 
using namespace std;
 
int main(void){
 
    long long n,flag,number;
    long long money,sum;
    long long data[4001*5]={0},dataF[4001*5]={0};
    queue<long long> ok;
 
    while(1){
 
        for(int i=0;i<=4001*5;i++) data[i]=0,dataF[i]=0;
        flag=0;
 
        cin>>n;
        if(n==0) break;
 
        for(int i=0;i<n;i++){
            cin>>number>>money>>sum;
            data[number]+=money*sum;
            if(dataF[number]==0){
                dataF[number]=1;
                ok.push(number);
            }
        }
            while(!ok.empty()){
                if(data[ok.front()]>=1000000){
                    cout<<ok.front()<<endl;
                    flag=1;
                }
                ok.pop();
            }
            if(flag==0) cout<<"NA"<<endl;
    }
 
    return 0;
}
 

Measured memory_bytes: 1536
#include <cstdio>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e2+5;
int n, m;
char s[N][N], a[N][N], b[N][N];
int main()
{
    n = read(), m = read();
    for(int i = 1; i <= n; ++i) scanf("%s", s[i]+1);
    for(int i = 1; i <= n; ++i) 
        for(int j = 1; j <= m; ++j)
            a[i][j] = b[i][j] = s[i][j];
    for(int i = 1; i <= n; ++i) a[i][1] = b[i][m] = '#';
    for(int i = 1; i <= n; ++i)
        for(int j = 2; j < m; ++j)
            i&1?a[i][j] = '#':b[i][j] = '#';
    for(int i = 1; i <= n; ++i) printf("%s\n", a[i]+1); puts("");
    for(int i = 1; i <= n; ++i) printf("%s\n", b[i]+1);
    return 0;
}

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

int main() {
  int N, x, max_x;
  cin >> N;
  char S[N];
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I') {
      x++;
    }
    else {
      x--;
    }
    if (x > max_x) {
      max_x = x;
    }
  }
  cout << max_x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.14159265
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
int main()
{
    int n,x;
    cin>>x>>n;
    int a[n];
    int d[102]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
        d[a[i]]=1;
    }
    int ab=INT_MAX,ans;
    for(int i=0;i<=101;i++){
        if(d[i]==0){
            if(abs(i-x)<ab){
                ab=abs(i-x);
                ans=i;
            }
        }
    }
    cout<<ans;
}



Measured memory_bytes: 3636
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e18
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main(){
	int n;
	cin >> n;
	vector<int> dp(n+1,0);
	dp[0] = 0;
	rep(i, n + 1) {
		if (i == 0) continue;
		int six=1e7, nine=1e7;
		rep(j, 10) {
			if (i < pow(6, j)) break;
			six = min(six, dp[i - pow(6, j)]);
		}
		rep(j, 10) {
			if (i < pow(9, j)) break;
			nine = min(nine, dp[i - pow(9, j)]);
		}
		if (six ==1e7 && nine ==1e7) continue;
		dp[i] = min(six, nine) + 1;
	}
	cout << dp[n] << endl;
	return 0;
}

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

using namespace std;

const int N = 1e6+5;

int dist[N];
vector < pair <int, int> > g[N];
vector <int> new_g[N], all[N];
int was[N];
int x[N];
int ptr[N];
int is[N];

template<typename Ty>
bool read1n(Ty &x)
{
    char ch; bool neg=false;
    for(ch=getchar();ch<'0'||'9'<ch;ch=getchar())
        if(ch=='-')
            neg=true;
        else if(ch==-1)return false;
    for(x=0;'0'<=ch&&ch<='9';ch=getchar())
        x=(x<<1)+(x<<3)+ch-'0';
    if(neg) x=-x;
    return true;
}

int main() {
  int n, m;
  while(1){
    if(!read1n(n))break;
    read1n(m);
    memset(dist,0,sizeof(dist));
    memset(x,0,sizeof(x));
    memset(is,0,sizeof(is));
    for(int i=0;i<n;i++)g[i].clear();
  for (int i = 0; i < m; i++) {
    int foo, bar, qwe;
    read1n(foo);
    read1n(bar);
    read1n(qwe);
    if(is[qwe]==0)all[qwe].clear();
    is[qwe]+=2;
    foo--; bar--;
    g[foo].push_back(make_pair(qwe, bar));
    g[bar].push_back(make_pair(qwe, foo));
    all[qwe].push_back(foo);
    all[qwe].push_back(bar);
  }
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end());
    ptr[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    was[i] = -1;
  }
  int new_n = n;
  for (int color = 0; color < N; color++) {
    if (is[color]==0) {
      continue;
    }
    for (int it = 0; it < is[color]; it++) {
      int v = all[color][it];
      if (was[v] == color) {
        continue;
      }
      int b = 0, e = 1;
      x[0] = v;
      was[v] = color;
      while (b < e) {
        while (ptr[x[b]] <  g[x[b]].size()) {
          int c = g[x[b]][ptr[x[b]]].first;
          if (c != color) {
            break;
          }
          int u = g[x[b]][ptr[x[b]]].second;
          if (was[u] != color) {
            was[u] = color;
            x[e] = u;
            e++;
          }
          ptr[x[b]]++;
        }
        b++;
      }
      for (int i = 0; i < e; i++) {
        new_g[x[i]].push_back(new_n);
        new_g[new_n].push_back(x[i]);
      }
      new_n++;
    }
  }
  for (int i = 0; i < new_n; i++) {
    dist[i] = -2;
  }
  int b = 0, e = 1;
  x[0] = 0;
  dist[0] = 0;
  while (b < e) {
    for (int j = 0; j <  new_g[x[b]].size(); j++) {
      int u = new_g[x[b]][j];
      if (dist[u] == -2) {
        dist[u] = dist[x[b]] + 1;
        x[e] = u;
        e++;
      }
    }
    b++;
  }
  printf("%d\n", dist[n - 1] / 2);
  for (int i = 0; i < new_n; i++) {
    new_g[i].clear();
  }
  }
  return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  
  if (a <= 5) cout << 0 << endl;
  else if (a >= 6 && a <= 12) cout << b / 2 << endl;
  else cout << b << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	ll H;
	scanf("%lld",&H);

	ll ans = 0;

	ll num = 1;

	while(true){

		ans += num;
		H /= 2;
		if(H == 0)break;

		num *= 2;
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = 0;
  ll c = 0;
  if(n < a)
  {
    cout << n << endl;
  }
  else
  {
    ans += n/(a+b)*a;
    c = n%(a+b);
    if(c > a)
    {
      ans += a;
    }
    else
    {
      ans += c;
    }
    cout << ans << endl;
  }
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

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

ll N, h[111];
ll i, j, k,ans;
map<ll, int> mp;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &h[i]);
    }
    fornum(i,0,100){
        k = 0;
        fornum(j,0,N){
            if(i+1<=h[j]){
                if(k==0){
                //printf("%lld:%lld ", i,j);
                ans++;
                k = 1;
                }
            }else{
                k = 0;
            }
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#ifdef sahdsg
#define DBG(...) printf(__VA_ARGS__)
#else
#define DBG(...) (void)0
#endif // sahdsg

using namespace std;
typedef long long LL;
int main()
{
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);
    int ans;
    if(c>a+b) {
        ans=(b)+(a+b+1);
    } else {
        ans=c+b;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
        for (h = 0; h < H; h++) {
            for (w = 0; w < W; w++) putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2060
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int aPlusB = a + b;
    
    if (aPlusB >= 24) {
      System.out.println(aPlusB - 24);
    } else {
      System.out.println(aPlusB);
    }
  }
}

Measured memory_bytes: 22608
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        Integer[] xList = new Integer[n];
        Integer[] yList = new Integer[m];
        for(int i = 0;i < n;i++) xList[i] = scanner.nextInt();
        for(int j = 0;j < m;j++) yList[j] = scanner.nextInt();
        Arrays.sort(xList, Collections.reverseOrder());
        Arrays.sort(yList);
        boolean war = true;
        for(int z = x + 1;z <= y;z++) if(xList[0] < z&&yList[0] >= z) war = false;
        if(war){
            System.out.println("War");
        }else{
            System.out.println("No War");
        }
    }
}

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

int main(){
	int r, D, x[12];
	int i = 0;
	cin >> r >> D >> x[i];
	
	for(i=0; i<10; i++){
		x[i+1] = r*x[i] - D;
		cout << x[i+1] << endl;
	}
	return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int A, B; cin >> A >> B;
    if(A >= 10 || B >= 10) cout << -1 << endl;
    else  cout << A*B << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 768
amount,dislike = map(int,input().split())
l = list(map(str,input().split()))
temp = {"0","1","2","3","4","5","6","7","8","9"} 
like = list(set(temp)-set(l))
i=0
for n in range(amount,100000):
  k =[]
  i = n
  k.append(str(i%10))
  i = i-i%10
  if n>=10:
    k.append(str(i%100//10))
    i = i-i%100
    if n>=100:
      k.append(str(i%1000//100))
      i = i-i%1000
      if n>=1000:
        k.append(str(i%10000//1000))
        i = i-i%10000
        if n>=10000:
          k.append(str(i%100000//10000))
  if len(list(set(k)-set(like))) ==0:
    print(n)
    break
 
  
      
    
  
  
  

Measured memory_bytes: 68152
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    dp = [[0] * (M+1) for _ in range(N+1)]
    
    for i in range(1, N+1):
        for j in range(1, M+1):
            p = (S[i-1] == T[j-1])
            dp[i][j] = max(dp[i-1][j], dp[i][j-1], dp[i-1][j-1] + p)
            
    ans = []
    x, y = N, M
    while x and y:
        if dp[x][y] == dp[x-1][y]:
            x -= 1
        elif dp[x][y] == dp[x][y-1]:
            y -= 1
        else:
            x -= 1
            y -= 1
            ans.append(S[x])
        
    print(''.join(reversed(ans)))


if __name__ == "__main__":
    main()

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

int main() {
  ll a;
  double b;
  ll ans;
  cin >> a >> b;
  b = 100*b+0.5;
  ans = int(b) * a /100;
  cout << ll(ans) <<endl;
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Raag4924 ios_base::sync_with_stdio(0);
#define fastio cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Raag4924
    fastio
 
  
    
    int n,m,x;
    cin>>n>>m>>x;

    

    int cost[n];
    int arr[n][m];

    for(int i=0;i<n;i++)
    {
        cin>>cost[i];
        for(int j=0;j<m;j++) cin>>arr[i][j];
    }

    
    int ans =INT_MAX;

    for(int i=1;i<(1<<n);i++)
    {
        vector<int>knowledge(m);
        int cost1=0;
        vector<int>books;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            books.pb(j);
        }
        
     

        for(auto it:books)
        {
            cost1+=cost[it];
            for(int j=0;j<m;j++)
            knowledge[j]+=arr[it][j];
        }
        int flag=0;
        for(int j=0;j<m;j++)
        {
            if(knowledge[j]<x)
            {
                flag = 1;
                break;
            }
        }

       

        if(flag==0)
        ans = min(ans,cost1);
    }

    if(ans==INT_MAX)
    cout<<"-1\n";
    else cout<<ans<<"\n";

 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 3784
x1,y1,x2,y2=list(map(int,input().split()))

x_diff=x2-x1
y_diff=y2-y1
x3=x2-y_diff
y3=y2+x_diff
x4=x3-x_diff
y4=y3-y_diff

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mod 1000000007
#define M 998244353
#define PI 3.141592653589793
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    int a,b,c;
    IN a>>b>>c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2)
    {
        OUT "Yes"<<endl
    }
    else
    {
        OUT "No"<<endl
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 3e6 + 5;

ll n, m, query;

ll a[N];

ll fact[N];

void Solve(){
    cin >> n >> m;
    if((m + n) % 3){
        cout << 0;
        return;
    }
    fact[0] = 1;
    for(int i = 1; i <= 3e6; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    ll cnt1 = 0, cnt2 = 0;
    ll m1 = m, n1 = n;
    while(m1 != 2 * n1){
        m1 -= 1;
        n1 -= 2;
        cnt1++;
        if(n1 < 0){
            cout << 0;
            return;
        }
    }
    m1 = m, n1 = n;
    while(2 * m1 != n1){
        m1 -= 2;
        n1 -= 1;
        cnt2++;
        if(m1 < 0){
            cout << 0;
            return;
        }
    }
    m = cnt1;
    n = cnt2;
    cout << fact[m + n] * Powmod((fact[m] * fact[n]) % MOD, MOD - 2) % MOD;
}

int main(){
    Speed;
    int query = 1; // cin >> query;
    while(query--){
        Solve();
    }
}






Measured memory_bytes: 24832
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Engines
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_N2 = MAX_N * 2;
const double PI = acos(-1.0);

/* typedef */

typedef long long ll;

struct TVec {
  double th;
  int x, y;
  TVec() {}
  TVec(double _th, int _x, int _y): th(_th), x(_x), y(_y) {}
  bool operator<(const TVec &tv) const { return th < tv.th; }
};

/* global variables */

TVec tvs[MAX_N2];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    tvs[i] = TVec(atan2(y, x), x, y);
  }

  sort(tvs, tvs + n);
  for (int i = 0; i < n; i++) tvs[i + n] = tvs[i];

  ll maxd2 = 0;
  for (int i = 0; i < n; i++) {
    int xm = 0, ym = 0;
    for (int j = 0, k = i; j < n; j++, k++) {
      xm += tvs[k].x, ym += tvs[k].y;
      ll d2 = (ll)xm * xm + (ll)ym * ym;
      if (maxd2 < d2) maxd2 = d2;
    }
  }

  printf("%.12lf\n", sqrt((double)maxd2));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll A[1010];
ll solve() {
	var(int, n, k);
	int a;
	rep(i, 0, n) {
		cin >> a;
		A[i + 1] = A[i] + a;
	}
	vll B, T;
	rep(i, 0, n) {
		rep(j, i + 1, n + 1) {
			B.eb(A[j] - A[i]);
		}
	}
	ll ans = 0;
	rrep(i, 40, -1) {
		T.clear();
		each(b, B) {
			if (b >> i & 1) {
				T.eb(b);
			}
		}
		if (len(T) >= k) {
			ans |= 1LL << i;
			B.clear();
			B = T;
		}
	}
	return ans;
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;

int main(void){
	long double W, H, x, y;
	cin >> W >> H >> x >> y;
	long double areaTotal = W * H / 2;
	long double answer;
	if (x == W / 2 && y == H / 2){
		answer = 1;
	}
	else {
		answer = 0;
	}

	cout << areaTotal << " " << answer << endl;
}

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

n = int(input())
T = [[] for _ in range(n+1)]
for _ in range(n-1):
  u, v = map(int, input().split())
  T[u].append(v)
  T[v].append(u)
ans = 0
for i in range(1, n+1):
  temp = 1
  for j in T[i]:
    if j < i:
      temp -= 1
      ans += (i-j) * (n+1-i)
  ans += temp * (n+1-i) * i
print(ans)

Measured memory_bytes: 101944
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main(){
	int N;
	cin >> N;
	out(N + N * N + N * N * N);
}

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

#define MAXN 200010
#define ll long long
#define mod 1000000007

using namespace std;

int n, sum = 1, k;

ll a[MAXN], fac[MAXN];

int qp(int x, int y) {
	ll res = 1, base = x;
	while (y) {
		if (y & 1) {
			res = (res * base) % mod;
		}
		base = (base * base) % mod;
		y >>= 1;
	}
	return res;
}

ll F(int x, int y) {
	if (y > x) return 0;
	return ((fac[x] * a[y]) % mod) * a[x - y] % mod;
}

int main() {
	cin >> n >> k;
	a[0] = 1;
	fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = (ll)(fac[i - 1] * i) % mod;
		a[i] = qp(fac[i], mod - 2);
	}
	for (ll i = 1; i <= min(n - 1, k); i++) {
		ll ssum = F(n, i);
		ll t = n - i, u = F(n - 1, n - t);
		sum = (sum + ssum * u % mod) % mod;
	}
	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 3328
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  vi w(n);
  scan(w);
  vi accum(n+1, 0);
  rep (i, n) {
    accum[i+1] = accum[i] + w[i];
  }
  int ans = accum[n];
  FOR (i, 1, n) {
    int w1 = accum[i];
    int w2 = accum[n] - w1;
    ans = min(ans, abs(w1 - w2));
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0;i < (n);++i)
#define FOR(i, a, b) for (int i=(a);i<(b);++i)
#define FORR(i, a, b) for (int i=(a);i>=(b);--i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int x[3], y[3];
double d[3];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  
  REP(i, 3) cin >> x[i] >> y[i];
  double mx = 0, sum = 0;
  REP(i, 3) {
    d[i] = hypot(x[i]-x[(i+1)%3], y[i]-y[(i+1)%3]);
    chmax(mx, d[i]);
    sum += d[i];
  }
  x[1] -= x[0]; y[1] -= y[0];
  x[2] -= x[0]; y[2] -= y[0];
  double S = abs(x[1]*y[2]-x[2]*y[1])/2.0;
  double r = 2*S/sum;
  cout << r*mx/(2*r+mx) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[2000005];
int main()
{
    /*string s;
    int cnt=0;
    cin >> s;
    int mx=0;;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')
            cnt++;
        else
        {
            mx = max(cnt,mx);
            cnt=0;
        }
    }
    mx = max(cnt,mx);
    cout << mx << endl;*/
    int ans=0;
    int  n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=n-2;i++)
    {
        for(int j=i+1;j<=n-1;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
                    ans++;
            }
        }
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

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



int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(ALL(a));

  ll nn = a[n-1];
  ll temp = a[n-1];
  int index = n-1;
  rep(i, n-1) {
    if(abs(nn/2 - a[i]) < temp) {
      temp = abs((nn+1)/2 - a[i]);
      index = i;
    }
  }
  cout << nn << " " << a[index] << "\n";
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

    int H,W,i,j;
    scanf("%d %d",&H,&W);

    while( H  !=0  || W != 0){
      for( j= 1 ; j<=H ; j++ ){
        for( i= 1 ; i<=W ; i++ ){
          printf("#");
        }
        printf("\n");
      }
      scanf("%d %d",&H,&W);
      printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include<stdio.h>

int main(){
	long long x,m=1e9+7;
	scanf("%lld",&x);
	long long a,b=1,c,d;
	for(a=1;a<=x;a++){
		b*=a;
		b=b%m;
	} 
	printf("%d",b);
} 

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrep1(i,n) for(int i=n;i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll ans = 0;
	rep(i, 1 << n) {
		string r, b;
		rep(j, n) {
			int mask = 1 << j;
			if (i & mask) {
				r.push_back(s[j]);
			}
			else {
				b.push_back(s[j]);
			}
		}
		reverse(all(b));
		string r_d = r + b;
		string b_d = r_d;
		reverse(all(b_d));
		reverse(all(b));
		vii dp(n + 1, vi(n + 1));
		dp[0][r.size()] = 1;
		rep(j, n) {
			rep(k, n + 1) {
				if (!in(n + j - k, 0, n + 1)) {
					continue;
				}
				if (s[n + j] == r_d[k]) {
					dp[j + 1][k + 1] += dp[j][k];
				}
				if (s[n + j] == b_d[n + j - k]) {
					dp[j + 1][k] += dp[j][k];
				}
			}
		}
		ans += dp[n][n];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
        sc.Scan()
        i, e := strconv.Atoi(sc.Text())
        if e != nil {
                panic(e)
        }
        return i
}

func main() {
        sc.Split(bufio.ScanWords)
        W := nextInt()
        H := nextInt()
        x := nextInt()
        y := nextInt()
        r := nextInt()

        if x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0 {
                fmt.Println("Yes")
        } else {
                fmt.Println("No")
        }
}


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

typedef long long ll;
ll sum[200010];

int bin_s(int l, int r) {
	ll g = (sum[l] + sum[r]) / 2;
	int ok = l, ng = r;
	while (ok + 1 < ng) {
		int mid = (ok + ng) / 2;
		if (sum[mid] <= g) ok = mid;
		else ng = mid;
	}
	if (g - sum[ok] < sum[ng] - g) return ok;
	else return ng;
}

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		ll A; cin >> A;
		sum[i + 1] = sum[i] + A;
	}
	ll ans = 1e15;
	for (int i = 2; i + 2 <= N; ++i) {
		int form = bin_s(0, i), latt = bin_s(i, N);
		ll mn = min(sum[form], sum[i] - sum[form]), mx = max(sum[form], sum[i] - sum[form]);
		mn = min(mn, min(sum[latt] - sum[i], sum[N] - sum[latt]));
		mx = max(mx, max(sum[latt] - sum[i], sum[N] - sum[latt]));
		ans = min(ans, mx - mn);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792