akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// 正の整数n未満の素数を全て求める
vector<int> sieve(int n) {
  vector<bool> is_prime(n);
  rep(i, n) is_prime[i] = true;

  is_prime[1] = false;
  for (int i = 4; i < n; i += 2) is_prime[i] = false;
  ll lim = ll(sqrt(n));
  for (int i = 3; i <= lim; i += 2) {
    for (int j = 3; i * j < n; j += 2) {
      is_prime[i * j] = false;
    }
  }

  vector<int> ret;
  for (int i = 1; i < n; i++) {
    if (is_prime[i]) ret.push_back(i);
  }
  return ret;
}

void solve() {
  const ll MAX = 100000;
  vector<ll> a(MAX + 1, 0);
  vector<ll> primes = sieve(MAX);

  ll sum = 0;
  for (int i = 1; i <= MAX; i += 2) {
    if (binary_search(all(primes), i) && binary_search(all(primes), (i + 1) / 2)) sum++;
    a[i] = a[i-1] = sum;
  }

  ll q; cin >> q;
  rep(i, q) {
    ll li, ri; cin >> li >> ri;
    if (li == 1) outl(a[ri]);
    else if (ri == 1) outl(0);
    else outl(a[ri] - a[li - 2]);
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1652
import java.util.*;
class Main{
    static Scanner sc = new Scanner(System.in);
    /*
     * 整数 -> nextInt() (遅い場合は下のni())
     * 単語 -> next()
     * 1行 -> nextLine()
     * 注意 : nextLIneをnext(),nextInt()のあとに呼び出す場合、次が改行だと改行だけ取ってしまうので注意
     */

    public static void main(String[] args){
        int H = ni();
        int W = ni();

        char[][] A = new char[H][W];
        for(int i=0;i<H;i++){
            A[i] = sc.next().toCharArray();
        }

        for(int x1=0;x1<H;x1++) for(int y1=0;y1<W;y1++){
            for(int x2=0;x2<H;x2++) for(int y2=0;y2<W;y2++){
                if(x1<x2 && y2 < y1 && A[x1][y1]=='#' && A[x2][y2]=='#'){
                    System.out.println("Impossible");
                    return;
                }
            }
        }

        System.out.println("Possible");
    }

    public static int ni(){
        return Integer.parseInt(sc.next());
    }
}


Measured memory_bytes: 23124
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 5000 + 10;
int MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, DP[N][N], zar[N], sm[N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> MOD;
	int k = (n / 2) + 1;
	for (int i = 2; i <= n; i++){
		if (i <= k) zar[i] = i - 1;
		else zar[i] = n - i + 2;
//		cout << zar[i] << '\n';
	}
	DP[1][0] = 1;
	for (int i = 2; i <= n; i++){
		memset(sm, 0, sizeof sm);
		for (int j = 0; j <= n; j++) sm[j] = ((j >= zar[i]?sm[j - zar[i]]:0) + DP[i - 1][j]) % MOD;
		for (int sum = 0; sum <= n; sum ++){
			DP[i][sum] = sm[sum];
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) ans = (ans + (n - i) * 1ll * DP[n][i] % MOD) % MOD;
	cout << ans;








	return 0;
}


Measured memory_bytes: 101472
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

dp = [[[0.0]*(N+2) for _ in range(N+2)] for _ in range(N+2)]
CA = Counter(A)
SA = CA[1]
SB = CA[2]
SC = CA[3]
for c in range(SC+1):
    for b in range(SB+SC+1):
        if b + c > N:
            break
        for a in range(N+1):
            if a + b + c > N:
                break
            S = a + b + c
            if S == 0:
                continue
            dp[a][b][c] = N/S + a/S*dp[a-1][b][c]\
            +b/S*dp[a+1][b-1][c]\
            +c/S*dp[a][b+1][c - 1]

print(dp[SA][SB][SC])

Measured memory_bytes: 257032
s = list(input())
YYMM = 0
MMYY = 0
if 1 <= int(s[2]+s[3]) <= 12:
    YYMM = 1
if 1 <= int(s[0]+s[1]) <= 12:
    MMYY = 1
 
if MMYY == YYMM == 1:
    print("AMBIGUOUS")
elif YYMM == 1:
    print("YYMM")
elif MMYY == 1:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 38256
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
cnt = 0
#-A1がマイナスならXと同じにならない-#
a1 = int(input())
if a1 != 0:
    print(-1)
#-A1<A2=A1+1なら+1,それ以外なら-1#
else:
    before = a1
    for i in range(1,N):
        a1 = int(input())
        if a1 == 0:
            continue
        elif a1==before+1:
            cnt += 1
        elif a1 <= before:
            cnt += a1
        else:
            print(-1)
            exit()
        before = a1
    print(cnt)


Measured memory_bytes: 9480
#include<iostream>
#include<set>
using namespace std;
int main()
{
    long long int n,k;
    scanf("%lld%lld",&n,&k);
    long long x=n%k;
    if(x==0)
        puts("0");
    else
        printf("%lld\n",min(n,k-x));
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <tuple>
#include <queue>

constexpr size_t m1 = -1;
constexpr size_t di[] = {m1, 0, 1, 0};
constexpr size_t dj[] = {0, m1, 0, 1};

using ban = std::vector<std::string>;
using zahyo = std::pair<size_t, size_t>;

bool nuru(ban& t, char c) {
  char c0 = t[0][0];
  size_t h = t.size();
  size_t w = t[0].length();
  std::queue<zahyo> q;
  q.emplace(0, 0);
  t[0][0] = c;
  while (!q.empty()) {
    size_t i, j;
    std::tie(i, j) = q.front();
    q.pop();
    for (int k = 0; k < 4; ++k) {
      size_t ni = i + di[k];
      size_t nj = j + dj[k];
      if (!(ni < h && nj < w)) continue;
      if (t[ni][nj] != c0) continue;
      t[ni][nj] = c;
      q.emplace(ni, nj);
    }
  }

  size_t res = 0;
  for (size_t i = 0; i < h; ++i)
    for (size_t j = 0; j < w; ++j)
      if (t[i][j] == c) ++res;

  return (res == h * w);
}

int testcase_ends() {
  size_t H, W;
  scanf("%zu %zu", &W, &H);
  if (H == 0 && W == 0) return 1;

  std::vector<std::string> s(H, std::string(W, '@'));
  for (size_t i = 0; i < H; ++i)
    for (size_t j = 0; j < W; ++j)
      scanf(" %c", &s[i][j]);

  {
    size_t count = 0;
    for (size_t i = 0; i < H; ++i)
      for (size_t j = 0; j < W; ++j)
        if (s[0][0] == s[i][j]) ++count;

    if (count == H * W) return puts("0"), 0;
  }

  std::string const color = "RGB";

  std::queue<std::pair<ban, int>> q;
  q.emplace(s, 0);
  while (!q.empty()) {
    ban b;
    size_t res;
    std::tie(b, res) = q.front();
    q.pop();
    for (char c: color) {
      if (b[0][0] == c) continue;
      ban t = b;
      if (nuru(t, c)) return !printf("%zu\n", res+1);
      q.emplace(t, res+1);
    }
  }
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#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(c) c.begin(),c.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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
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


vl num(52);
vl p(52);
vl add(52, -1);


pll dfs(int level, ll nokori) {
  pll res(0, 0);
  if (nokori == num[level]) {
    res = pll(p[level], num[level]);
    return res;
  }
  if (level == 0) {
    res = res + pll(1, 1);
    return res;
  }
  nokori--;
  res.second++;
  if (nokori > 0) {
    if (nokori >= num[level - 1]) {
      res = res + pll(p[level - 1], num[level - 1]);
      nokori -= num[level - 1];
    }
    else {
      pll temp = dfs(level - 1, nokori);
      nokori -= temp.second;
      res = res + temp;
    }
  }
  if (nokori > 0) {
    nokori--;
    res.first++;
    res.second++;
  }
  if (nokori > 0) {
    if (nokori >= num[level - 1]) {
      res = res + pll(p[level - 1], num[level - 1]);
      nokori -= num[level - 1];
    }
    else {
      pll temp = dfs(level - 1, nokori);
      nokori -= temp.second;
      res = res + temp;
    }
  }
  if (nokori > 0) {
    nokori--;
    res.second++;
  }
  return res;
}
      
  
int main() {
  int n;
  cin >> n;
  ll x;
  cin >> x;
  num[0] = 1;
  p[0] = 1;
  rep (i, n) {
    num[i + 1] = 3 + 2 * num[i];
    p[i + 1] = 1 + 2*p[i];
  }
  cout << dfs(n, x).first << endl;
  
}
  


Measured memory_bytes: 256
N,W = map(int, input().split())
ws = []
vs = []
for i in range(N):
    w,v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ws_m = [w-ws[0] for w in ws]

"""
i番目まで見て、n個選んでいて、重さがwのときのvの最大値
ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする
dp[i][n][w] 
"""
dp = [[-1]*(3*N+1) for i in range(N+1)]
dp[0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):    
    dp[i+1][:] = dp[i][:]
    for j in range(len(dp[i])):
        if dp[i][j] == -1:continue
        dp[i+1][j+w] = max(dp[i][j]+v, dp[i][j+w])
    # print(dp)

# print(dp[N][W-N*ws_m[0]])

dp = [[[-1]*(3*N+1) for i in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):
    # print(i,w,v)
    for n in range(N):
        # dp[i+1][n][:] = dp[i][n][:]
        for j in range(N):
            if dp[i][n][j] == -1:continue
            if dp[i][n][j]+v >= dp[i][n][j+w]:
                # print("aa",i,n,j,v)
                dp[i+1][n+1][j+w] = dp[i][n][j] + v
            else:
                dp[i+1][n][j+w] = dp[i][n][j+w]
            dp[i+1][n][j] = max(dp[i+1][n][j], dp[i][n][j])
    # print(dp[i])

# for i in range(N+1):
    # print("i個選んだやつ",dp[N][i])
anss = dp[N]
a = 0
for i,ans in enumerate(anss):
    w = W - i*ws[0]
    if w >= 0:
        a = max(a,max(ans[:w+1]))
print(a)   


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	ll n;cin>>n; vl a(n),b(n); repi(i,n) cin>>a[i]>>b[i];
	ll ans=0;
	sort(all(a));
	sort(all(b));
	if(n&1){
		db(b[n/2]-a[n/2]+1);	
	}
	else{
		db(b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1);	
	}
	
	
	
	
	 //*/
return 0;
}



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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
int main(){
    string s; cin >> s; lint n = s.size();
    lint f = 0, res = 0;
    repr(i, n){
        lint l = s[i] - '0';
        if(l + f < 5){
            res += l + f;
            f = 0;
        }
        else if(l + f == 5 && (i == 0 || (s[i-1]-'0') < 5)){
            res += l + f;
            f = 0;
        }
        else{
            res += 10 - (l + f);
            f = 1;
        }
    }
    out(res + f);
}

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

int main() {
  
  int A, B; cin >> A >> B; int ans = 0;
  
  for (int i = A; i <= B; i++) {
    
    int digit1 = i % 10;
    int digit2 = (i % 100) / 10;
    int digit4 = (i % 10000) / 1000;
    int digit5 = i / 10000;
    
    if (digit1 == digit5 && digit2 == digit4) ans++;
    
  }
  
  cout << ans << endl;
  
}

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

int main() {
    int N,W;
    cin >> N >> W;
    int v[N],w[N];
    for(int i=0;i<N;i++) cin >> v[i] >> w[i];

    ll dp[W+1];
    for(int i=0;i<=W;i++) dp[i]=0;
    for(int i=0;i<N;i++){
        for(int j=w[i];j<=W;j++){
            dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout << dp[W] << endl;
}



Measured memory_bytes: 3200
#include <stdio.h>
#include<string.h>
#include<stdlib.h>

int compare(const void *a,const void *b)
{
  return *(int*)a-*(int*)b;
}

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int i;
  int s[100]={};
  int ans=0;
  
  for(i=0;i<n;i++)
  {
    scanf("%d",&s[i]);
  }
  
  qsort(s,n,sizeof(int),compare);
  
  for(i=0;i<n;i++)
  {
    ans+=s[i];
  }
  
  int j;
  if(ans%10==0)
  {
   for(j=0;j<n;j++)
   {
     if(s[j]%10!=0)
     {
       ans-=s[j];
     break;
     }
   }
  }
  
  if(ans%10!=0)
  {
  printf("%d\n",ans);
  }
  else
  {
    printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
	Scanner scan=new Scanner(System.in);
	int x,a,b;
	x=scan.nextInt();
	a=scan.nextInt();
	b=scan.nextInt();
	int s,t;
	s=Math.abs(x-a);
	t=Math.abs(x-b);
	if(s<t)System.out.println("A");
	else System.out.println("B");
}
}


Measured memory_bytes: 23124
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ll A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	rep1(i, N) {
		A[i] = getint();
		A[i] += A[i - 1];
	}

	ll saishou = 1e18;
	int k = lower_bound(A + 1, A + N + 1, A[N] / 2) - A;
	if (k - 1 >= 1) chmin(saishou, abs(A[k - 1] * 2 - A[N]));
	chmin(saishou, abs(A[k] * 2 - A[N]));
	if (k + 1 <= N) chmin(saishou, abs(A[k + 1] * 2 - A[N]));

	printf("%lld", saishou);


	Would you please return 0;
}

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

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    string ans = "No";
    rep(i, s.size()) {
        if(s == t) {
            ans = "Yes";
            break;
        }
        string u = s.substr(s.size() - 1);
        s.insert(0, u);
        s.pop_back();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
using namespace std;


int main()
{
long double a,b,x;
cin>>a>>b>>x;

long double c;
if (a*a*b/2>x)
{c=2*x/(a*b);std::cout << std::setprecision(10) << std::scientific << 180*atan(b/c)/M_PI << std::endl;}
else 
{c=(2*x/(a*a))-b;std::cout << std::setprecision(10) << std::scientific << 180*atan((b-c)/a)/M_PI<< std::endl;
}
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 10000
#define Q 500
#define E 1000000000

main() {
  
  int n=0;
  int S[N];
  int q=0;
  int T[Q];
  int C=0;
  int i=0,j=0;
  
  scanf("%d",&n);
  
  if(n < 0 || N < n){
    return 0;
  }
  
  for(i=0;i < n;i++){
    scanf("%d",&S[i]);
    
    if(S[i] < 0 || E < S[i]){
      return 0;
    }
  }
  
  scanf("%d",&q);
  
  if(q < 0 || Q < q){
    return 0;
  }
  
  for(i=0;i < q;i++){
    scanf("%d",&T[i]);
    
    if(T[i] < 0 || E < T[i]){
      return 0;
    }
  }
  
  for(i=0;i < q;i++){
    for(j=0;j < n;j++){
      if(T[i] == S[j]){
	C++;
	break;
      }
    }
  }
  
  printf("%d\n",C);
  
  return 0;
}

Measured memory_bytes: 640
a, b, c, k = map(int, input().split())

if a + b >= k:
    saidai = min(a, k)
else:
    saidai = a - (k - (a + b))

# if b + c >= k:
#     saisho = -min(c, k)
# else:
#     saisho = -c + (k - (b + c))
print(saidai)



Measured memory_bytes: 9156
#include <stdio.h>

int main (void)
{
	double syu,men,pai;
	double r;

	scanf("%lf",&r);

	pai = 3.141592653589;

	men = r*r*pai;
	syu = 2*r*pai;

	printf("%f %f\n",men,syu);

	return 0;
}

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

string s;
int l, k, ans, c, n;
int main() {
  cin >> n >> k >> s;
  for (int r=0; r<n; r++) {
    if (s[r] == '0') {
      if (r == 0 or s[r - 1] == '1')
        c++;
    }
    if (c > k) {
      while (s[l] == '1') l++;
      while (s[l] == '0') l++;
      c--;
    }
    ans = max(ans, r - l + 1);
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> a(N); cin >> a;
    sort(ALL(a),greater<int>());
    int ans = 0;
    for (int i = 0; i < N; i++)
        i % 2 ? ans -= a[i] : ans += a[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int ret = 0;
    for(int i=0; i<4; ++i){
        int a;
        cin >> a;
        ret += a;
    }
    cout << (ret/60) << endl << (ret%60) << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:


const int limit = 100010;
int a[limit],num[limit];

template<int MOD> struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt(): x(0){}
	ModInt(signed sig) {int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int getval() const { return int(x); }
	inline int extgcd(int a,int b,int& x,int& y){x=1,y=0;int g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}


	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = 1LL * x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { int y,d; extgcd(that.x,MOD,y,d); return x = 1LL * x * y % MOD; return *this;}
	
	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
};

using mint=ModInt<1000000007>;

mint I[limit];
void inv_table(int n){I[1]=1LL;rep(i,2,n+1) I[i]=I[mint::Mod%i]*(mint::Mod-mint::Mod/i);}

mint F[limit],IF[limit];
void fact_table(int n){F[0]=IF[0]=1LL; rep(i,1,n+1) F[i]=F[i-1]*i,IF[i]=IF[i-1]*I[i];}

inline mint comb(int n,int k){return F[n]*IF[k]*IF[n-k];}


mint ans[limit];



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

	inv_table(limit);
	fact_table(limit);

	rep(i,n+1){
		cin >> a[i],a[i]--;
		num[a[i]]++;
	}

	rep(i,n+1) ans[i] = comb(n+1,i+1);

	int tar = -1;
	rep(i,n) if(num[i]==2) tar = i;

	int lft = -1 ,rht = -1;

	rep(i,n+1){
		if(a[i]!=tar) continue;
		if(lft == -1) 
			lft = i;
		else
			rht = i;
	}

	const int sum = lft + (n - rht);
	rep(i,sum+1) ans[i] -= comb(sum,i); 



	rep(i,n+1) cout << ans[i].getval() << endl;

	return 0;
}

Measured memory_bytes: 3584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        }

    }
}



Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 1e+8
#define MX_N 100
#define MX_W 10000

int vi[MX_N+1];
int wi[MX_N+1];
int dp[MX_N+1][MX_W+1];

int main() {
  int n, w;
  while(cin >> n >> w, n) {
    for (int i = 0; i < n; i++) {
      cin >> vi[i] >> wi[i];
    }
    for(int i = 0; i <= w; i++) dp[n][i] = 0;

    for(int i = n-1; i >= 0; i--) {
      for(int j = 0; j <= w; j++) {
        if (wi[i] > j) {
          dp[i][j] = dp[i+1][j];
        } else {
          dp[i][j] = max(dp[i+1][j], vi[i] + dp[i+1][j - wi[i]]);
        }
      }
    }
    cout << dp[0][w] << endl;
    n = 0;
  }
}

Measured memory_bytes: 5108
import sys
n, m = map(int, input().split())
sc = []
for _ in range(m):
    sc.append(tuple(map(int, input().split())))

cc = [None]*n

for s, c in sc:
    s -= 1
    if s==0 and c==0 and n!=1:
        print(-1)
        sys.exit()
    elif cc[s] is None:
        cc[s] = c
    elif cc[s] != c:
        print(-1)
        sys.exit()

if n==1:
    if cc[0] is None:
        print(0)
    else:
        print(cc[0])
    sys.exit()

for ind, i in enumerate(cc):
    if i is None:
        if ind==0:
            print(1, end='')
        else:
            print(0, end='')
    else:
        print(i, end='')
print()


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

int main()
{	
	int n, m;
	std::cin >> n;
	int* A = new int[n];
	for (int i=0; i<n; i++) std::cin >> A[i];
	std::cin >> m;
	int* B = new int[m];
	for (int i=0; i<m; i++) std::cin >> B[i];
	
	int* C = new int[n];
	for (int i=0; i<n; i++) C[i] = -1;
	std::set_difference(A, A+n, B, B+m, C);
	
	for (int i=0; i<n; i++) {
		if (C[i] < 0) break;
		std::cout << C[i] << std::endl;
	}
	
	delete[] A;
	delete[] B;
	delete[] C;
	
	return 0;
}



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

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll q,r;
  q = n / (a + b);
  r = n % (a + b);
  ll ans = q * a + min(r,a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    long long a, b;
    std::cin >> a >> b;

    if (a % 2 && b % 2) {
        std::cout << (a ^ ((b - a + 1) / 2 % 2)) << std::endl;
        return 0;
    }

    if (a % 2) {
        std::cout << (a ^ b ^ ((b - a - 1) / 2 % 2)) << std::endl;
        return 0;
    }

    if (b % 2) {
        std::cout << (b - a + 1) / 2 % 2 << std::endl;
        return 0;
    }

    std::cout << (b ^ ((b - a) / 2 % 2)) << std::endl;
}


Measured memory_bytes: 256
import sys

A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)

for s in sys.stdin:
    x,y,c = map(int, s.split())
    tmp = a[x-1] + b[y-1] - c
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 18612
#include<bits/stdc++.h>
#define ll long long
#define pa pair<ll,int>
#define mo 1000000007
#define N 100005 
using namespace std;
ll ds[N],dt[N],ways[N],wayt[N];
struct edge{int to,next,v;}e[N*4];
int head[N],vis[N];
int n,m,s,t,tot,ans;
priority_queue<pa > q;
void add(int x,int y,int v){
	e[++tot]=(edge){y,head[x],v};
	head[x]=tot;
}
void dijk_heap(int S,ll *dis,ll *way){
	for (int i=1;i<=n;i++)
		dis[i]=1e18,vis[i]=0,way[i]=0;
	dis[S]=0; way[S]=1;
	while (!q.empty()) q.pop();
	q.push(pa(0,S));
	while (!q.empty()){
		int x=q.top().second; q.pop();
		if (vis[x]) continue; vis[x]=1;
		for (int i=head[x];i;i=e[i].next){
			ll tmp=dis[x]+e[i].v;
			if (dis[e[i].to]>tmp){
				dis[e[i].to]=tmp;
				way[e[i].to]=0;
				q.push(pa(-tmp,e[i].to));
			}
			if (dis[e[i].to]==tmp)
				way[e[i].to]=(way[e[i].to]+way[x])%mo;
		} 
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for (int i=1;i<=m;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		add(x,y,z);
		add(y,x,z);
	}
	dijk_heap(s,ds,ways);
	ans=1ll*ways[t]*ways[t]%mo;
	dijk_heap(t,dt,wayt);
	for (int i=1;i<=n;i++)
		if (ds[i]*2==ds[t]&&ds[i]+dt[i]==ds[t])
			ans=(ans+mo-1ll*ways[i]*ways[i]%mo*wayt[i]%mo*wayt[i]%mo)%mo;
	for (int x=1;x<=n;x++)
		for (int i=head[x];i;i=e[i].next)
			if (ds[x]+e[i].v+dt[e[i].to]==ds[t])
				if (ds[x]*2<ds[t]&&dt[e[i].to]*2<ds[t])
					ans=(ans+mo-1ll*ways[x]*wayt[e[i].to]%mo*ways[x]%mo*wayt[e[i].to]%mo)%mo;
	printf("%d\n",ans);
}


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

using namespace std;

long long a = 0, b = 0, x = 0;

int main(){
  cin >> x;
  cin.ignore();

  // マイナス方向の探索

  double db_a;
  long long b5;
  for(long long b_ = 0; b_*b_*b_*b_*b_ <= x; b_++){
    b5 = b_*b_*b_*b_*b_;
    db_a = pow((double)(x - b5), 0.2);
    a = round(db_a);
    if(a*a*a*a*a == x - b5){
      if(b_ == 0){
        cout << a << " " << 0 << endl;
        return 0;
      }
      cout << a << " -" << b_ << endl;
      return 0;
    }
  }

  // プラス方向のループ

  b = 1;
  double db_b = 1;
  double b5db;
  while(true){
    b5 = b*b*b*b*b;
    b5db = db_b*db_b*db_b*db_b*db_b;
    //db_a = pow((double)(x+b5db), 0.2);
    db_a = pow((double)(x+b5), 0.2);
    a = round(db_a);
    //if(db_b == 2) cout << a << " " << db_a << endl;
    if(a*a*a*a*a == x+b5){
      cout << a << " " << b << endl;
      return 0;
    }
    ++b;
    db_b += 1;
    //cout << db_b << endl;
  }
  return 0;
}


Measured memory_bytes: 4008
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  int N;
  cin>>N;
  double ANS = 0;
  for (int i = 0; i < N; i++)
  {
    double A;
    string str;
    cin>>A>>str;
    if(str == "JPY")
    ANS += A;
    else
    ANS += A* (double)380000;

  }
  cout<<ANS<<endl;
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define N 55
using namespace std;

typedef long long ll;
ll n, k, mx, v[N];
vector<ll> a;

void f(int p) {
	ll i, s = 0;
	if (p < 0) return;
	sort(a.begin(), a.end());
	for (i = 0; i < a.size(); i++) {
		if (i < p && a[i] < 0) continue;
		s += a[i];
	}
	mx = max(mx, s);
}

int main()
{
	ll i, j;
	cin >> n >> k;
	for (i = 1; i <= n; i++) scanf("%lld", &v[i]);
	for (i = 0; i < n; i++) {
		a.clear();
		for (j = 1; j <= i; j++) a.push_back(v[j]);
		f(k - a.size());
		for (j = n; j > i; j--) {
			a.push_back(v[j]);
			f(k - a.size());
		}
	}
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int  main (){
  int  a ,  b ;
  scanf ("%d%d" , &a , &b ) ;
  int  r = 0;
  for( int  i = a ;  i<= b ;  i++){
    int  s = i % 10 ,  t = i  / 10000 % 10;
    int  u = i  / 10 % 10 , v = i  / 1000 % 10;
    if ( s == t&&u == v) r++;
  }
     printf ("%d" ,  r ) ;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
int N;
map<string, int> m;


int main(void) {
    scanf("%d", &N);
    rep(i, 0, N) {
        string s;
        cin >> s;
        m[s]++;
    }
    int maxt = -1;
    for (auto itr = m.bg; itr != m.en; itr++) {
        maxt = max(maxt, itr->second);
    }
    for (auto itr = m.bg; itr != m.en; itr++) {
        if (itr->second == maxt) cout << itr->first << endl;
    }



	return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n;
string s, t;
cin >> n >> s >> t;
ll ans = INF;
for (ll i = n - 1; i > -1; i--) {
    if (s.substr(i, n - i) == t.substr(0, n - i)) chmin(ans, n + i);
}
chmin(ans, 2 * n);
cout << ans << endl;
}

Measured memory_bytes: 3636
A,B,C=map(int,input().split())
if B>=A and B>=C:
    D=A
    A=B
    B=D
elif C>=A and C>=B:
    D=A
    A=C
    C=D
R=(A-B)%2-(A-C)%2
if R==0:
    print(A+(-B-C)//2)
else:
    print(A+(-B-C+3)//2)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

const int nmax=100005;
const int mod=1e9+7;

int n,dp[nmax][2];
vector<int>nod[nmax];

void DFS(int s,int par){
    dp[s][1]=dp[s][0]=1;
    for(auto it:nod[s]){
        if(it!=par){
            DFS(it,s);
            dp[s][1]=dp[s][1]*((dp[it][0]+dp[it][1])%mod)%mod;
            dp[s][0]=dp[s][0]*dp[it][1]%mod;
        }
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    for(int i=1;i<n;i++){
        int x,y;
        cin >> x >> y;
        nod[x].push_back(y);
        nod[y].push_back(x);
    }
    DFS(1,0);
    cout << (dp[1][1]+dp[1][0])%mod;
}


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

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

int main(){
  int N;
  cin >>N;
  vector <double> v(N);
  rep(i,N)
    cin >>v[i];
  sort(v.begin(),v.end());
  double count1=0,count2=0,ans;
  rep(i,N-1){
    v[i+1]=(v[i]+v[i+1])/2;
    
  }
  cout <<v[N-1]<<endl;


  return 0;
}


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


int main() {

  int a,b,c ; cin >> a >> b >> c ;
  
  if ( a == 5 ) {
  if ( (b == 7 && c == 5) || ( b == 5 && c == 7) ) cout << "YES" ;
  else cout << "NO" ;
  }
  else if ( a == 7 ) {
  if ( b == 5 && c == 5 ) cout << "YES";
  else cout << "NO" ; 
  }
  else cout << "NO" ;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A,B;
	char S[13];
	scanf("%d%d", &A, &B);
	scanf("%s", S);
	int i = 0;
	if (S[A] != '-')
	{
		printf("No");
		return 0;
	}
	while (i < A)
	{
		if (!(S[i] >= '0' && S[i] <= '9'))
		{
			printf("No");
			return 0;
		}
		i++;
	}
	i++;
	while (i <= A+B)
	{
		if (!(S[i] >= '0' && S[i] <= '9'))
		{
			printf("No");
			return 0;
		}
		i++;
	}
	printf("Yes");
	return (0);
}

Measured memory_bytes: 128
# Reference: https://tjkendev.github.io/procon-library/python/max_flow/dinic.html

from collections import deque
from sys import setrecursionlimit
setrecursionlimit(10**9)

class Dinic:
    def __init__(self, n):
        self.n = n
        self.G = [[] for _ in range(n)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def bfs(self, source, sink):
        self.level = level = [None] * self.n
        deq = deque([source])
        level[source] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[sink] is not None

    def dfs(self, v, sink, f):
        if v == sink:
            return f
        level = self.level
        for edge in self.it[v]:
            w, cap, rev = edge
            if cap and level[v] < level[w]:
                d = self.dfs(w, sink, min(f, cap))
                if d:
                    edge[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, source, sink, inf=2**63 - 1):
        flow = 0
        G = self.G
        while self.bfs(source, sink):
            *self.it, = map(iter, self.G)
            f = inf
            while f:
                f = self.dfs(source, sink, inf)
                flow += f
        return flow

######

from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    n, m = map(int, input().split())
    s = [list(input()) for _ in range(n)]

    dnc = Dinic(n * m + 2)
    source = n * m
    sink = n*m + 1

    # add edges
    # from even ((i + j) % 2 == 0) to odd ((i + j) % 2 == 1)
    # (i, j) → m*i + j
    d = ((1, 0), (-1, 0), (0, 1), (0, -1))
    for i in range(n):
        for j in range(m):
            if s[i][j] == '#':
                continue

            ind = m*i + j

            if (i + j) % 2 == 0:
                dnc.add_edge(source, ind, 1)
                for dx, dy in d:
                    if 0 <= i + dx < n and 0 <= j + dy < m and s[i+dx][j+dy] == '.':
                        dnc.add_edge(ind, m*(i+dx) + j+dy, 1)
            else:
                dnc.add_edge(ind, sink, 1)

    # flow
    print(dnc.flow(source, sink))

    # rewrite the graph
    for ind in range(n * m):
        i, j = divmod(ind, m)

        if (i + j) % 2 == 1:
            continue

        for v, cap, rev in dnc.G[ind]:
            if v == source or v == sink or rev[1] == 0:
                continue

            x, y = divmod(v, m)

            if i + 1 == x:
                s[i][j] = 'v'
                s[x][y] = '^'
            elif i - 1 == x:
                s[i][j] = '^'
                s[x][y] = 'v'
            elif j + 1 == y:
                s[i][j] = '>'
                s[x][y] = '<'
            else:
                s[i][j] = '<'
                s[x][y] = '>'

    for row in s:
        print(''.join(row))

main()

Measured memory_bytes: 84392
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$K) = explode(" ",trim(fgets(STDIN)));
$P = array_map('intval',explode(" ",trim(fgets(STDIN))));
//function chmax(&$a,$b) {if ($a<$b){$a=$b;return true;}return false;}
//function chmix(&$a,$b) {if ($a>$b){$a=$b;return true;}return false;}

$res=0;

for($i=0;$i<$N;$i++) {
  $P[$i]++;
}
$s=0;
$mx=0;
$q = new SplQueue();
for($i=0;$i<$N;$i++) {
  $s+= $P[$i];
  $q->enqueue($P[$i]);
  if ($q->count()>$K) {
    $s-=$q->dequeue();
  }
  if ($q->count()==$K) {
    $mx = max($mx,$s);
  }
}
printf("%f\n",$mx/2);


Measured memory_bytes: 27120
H, W = map(int,input().split())
A=[list(input()) for _ in range(H)]
def cnt_(h,w):
  ret=0
  if 0<=h<H and 0<=w<W and A[h][w]=='#':
    ret=1
  return ret
def cnt(h,w):
  ret=0
  ret+=cnt_(h+1,w)+cnt_(h-1,w)
  ret+=cnt_(h,w+1)+cnt_(h,w-1)
  return ret
ans = "Yes"
for i in range(H):
  for j in range(W):
    if A[i][j]=='#':
      if cnt(i,j)==0:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

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

    vector<vector<ll>> A(n, vector<ll>(m, 0));
    vector<vector<ll>> B(m, vector<ll>(l, 0));
    vector<vector<ll>> C(n, vector<ll>(l, 0));

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

    for(int i=0; i<m; ++i) {
        for(int j=0; j<l; ++j) {
            cin >> B[i][j];
        }
    }

    ll sum;
    for(int i=0; i<n; ++i) {
        for(int j=0; j<l; ++j) {
            sum = 0;
            for(int k=0; k<m; ++k) {
                sum += (A[i][k] * B[k][j]);
            }
            C[i][j] = sum;
        }
    }

    for(int i=0; i<n; ++i) {
        for(int j=0; j<l; ++j) {
            cout << C[i][j];
            if (j != l-1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3244
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            int N = cin.nextInt();
            int R = cin.nextInt();

            if (N <= 10)
            {
                R = R + 100 * (10 - N);
            }

            Console.WriteLine(R);
        }
    }
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

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

  rep(i,1,n+1){
    if(pow(i,2) <= n) ans = pow(i,2);
    else break;
  }
  printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256