akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
// #include <unordered_map>
#include <cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m, n) for (int i = m; i < n; i++)
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
#define ST(x, y, z) sort(x + y, x + z);
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
#define re read()
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
// #define int ll
#define LL long long
#define int ll
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}

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

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

const int N = 2e5 + 10;
int a[N];
int b[N];
signed main()
{
    // STDIN
    int n, m, k;
    n = re, m = re, k = re;
    rep(i, 1, n)
    {
        a[i] = re;
        a[i] += a[i - 1];
    }
    rep(j, 1, m)
    {
        b[j] = re;
        b[j] += b[j - 1];
    }
    int ans = 0;
    int j = n;
    rep(i, 0, m)
    {
        if (b[i] > k)
            break;

        while (a[j] + b[i] > k && j > 0)
        {
            j--;
        }

        ans = max(ans, i + j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6720
#ITP1_10-B Triangle
import math as m
a,b,C = map(float,input().split(" "))
C = m.pi*C/180
h = b*m.sin(C)
print( a*h*0.5 )
print( (a**2+b**2 - 2*a*b*m.cos(C))**0.5 + a + b )
print( h )   

Measured memory_bytes: 7820
import Control.Monad
import Data.Function
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U

solve n m s lines exchanges = ans where
  ans =
    map (minimum . map snd)
    . tail
    . groupBy ((==) `on` fst)
    . ((1,0):)
    . map (\((v, _), (t, _)) -> (v, t))
    . M.toAscList
    $ dijkstra suc (1, min 2450 s)
  suc (u, s) = ex ++ [((v,s-a), b) | (v,a,b) <- adj V.! (u-1), s>=a] where
    ex = [((u, s+c), d) | s+c <= 2450]
    (c,d) = U.fromListN n exchanges U.! (u-1)
  adj =
    V.fromList . map snd . M.toAscList
    $ foldr addL (M.fromList . zip [1..n] $ repeat []) lines
  addL (u,v,a,b) = M.adjust ((v,a,b):) u . M.adjust ((u,a,b):) v

main = do
  [n, m, s] <- readWords
  lines <- replicateM m $ (\[a,b,c,d]->(a,b,c,d)) <$> readWords
  exchanges <- replicateM n $ (\[a,b]->(a,b)) <$> readWords
  mapM_ print $ solve n m s lines exchanges

readWords = map read . words <$> getLine

dijkstra suc st = M.delete st res where
  res = go (M.singleton st (0, st), S.singleton (0, st))
  go (res, que)
    | S.null que = res
    | otherwise = go $ foldl' f (res, S.deleteMin que) (suc u)
    where
      (du, u) = S.findMin que
      f (res, que) (v, cost)
        | v `M.member` res && fst (res M.! v) <= alt = (res, que)
        | otherwise = (M.insert v (alt, u) res, S.insert (alt, v) que)
        where alt = du + cost

Measured memory_bytes: 67588
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	unsigned long long int a, b;
	cin >> a >> b;
	int t = 0;
	while (a <= b) {
		t++;
		a *= 2;
	}
	cout << t;

	return 0;
}

Measured memory_bytes: 384
import sys
import math
#import random
#sys.setrecursionlimit(1000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

x,y=invr()

for i in range(x+1):
	a=i*2
	b=(x-i)*4
	
	if a+b==y:
		print("Yes")
		exit(0)

print("No")


	


Measured memory_bytes: 62172
#include<bits/stdc++.h>
 
using namespace std;
int main()
 
{
int a,b,c;
cin>>a>>b>>c;
 
if(a+b == c or b+c == a or c+a == b){
    cout<<"Yes"<<endl;
}
 
else cout<<"No"<<endl;
 
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://abc065.contest.atcoder.jp/tasks/abc065_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    X, A, B = map(int, input().split())
    if A >= B:
        print('delicious')
    elif (A + X) >= B:
        print('safe')
    else:
        print('dangerous')


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;

typedef int64 simple_t;

int compare_simple(const void *a, const void *b)
{
  simple_t *x;
  simple_t *y;

  x = (simple_t *)a;
  y = (simple_t *)b;

  if (x > y) return 1;
  if (y < x) return -1;

  return 0;
}
void qsort_simple (simple_t *array, int size)
{
  qsort(array, size, sizeof(simple_t), compare_simple);
}

int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}


int resolve1()
{
  int64 R;
  double pi=3.14159;
  double L;

  get_N(&R);

  L = pi*R*2;

  printf("%lf", L);
  return 0;
}

int resolve2()
{
  int64 N,M;
  int64 *A;
  int64 i;
  int64 total = 0;
  int64 play=0;
  
  get_NK(&N, &M);
  A = get_NSeq(M);

  for (i=0; i < M; i++) {
    total += A[i];
  }

  if (N >= total) {
    play = N - total;
  } else {
    printf("-1");
    return 0;
  }

  printf("%lld",play);
  return 0;
}


int main()
{
  int64 S,W;

  get_NK(&S, &W);

  if (W >= S) {
    printf("unsafe");
  } else {
    printf("safe");
  }
  
  return 0;
}



Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define sc(aa) scanf("%lld",&aa)
#define pr(aa) printf("%lld",aa)
#define line printf("\n")
#define space printf(" ")
#define loop(aa) for(ll ii=0;ii<aa;ii++)
using namespace std;
int main()
{
    ll n;
    while(sc(n)==1)
    {
        ll a[20],b[20],c[20];
        for(ll i=1;i<=n;i++)
        {
            sc(a[i]);
        }
        for(ll i=1;i<=n;i++)
        {
            sc(b[i]);
        }
        for(ll i=1;i<n;i++)
        {
            sc(c[i]);
        }

        ll ans=b[a[1]];

        for(ll i=2;i<=n;i++)
        {
            ans+=b[a[i]];
            if(a[i]-a[i-1]==1)ans+=c[a[i-1]];
        }
        pr(ans);
        line;
    }
}

//5 8 9 24 15 13



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

using namespace std;

typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define pb push_back
#define F first
#define S second
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;


void solve()
{
	ll n,m;
	cin>>n>>m;
	vector<string> a(n),b(m);
	fr(i,0,n)
		cin>>a[i];
	fr(j,0,m)
		cin>>b[j];
	ll ans=0;
	fr(i,0,(n-m+1))
	{
		fr(j,0,(n-m+1))
		{
			ll fg=1;
			fr(p,0,m)
			{
				fr(v,0,m)
				{
					if(b[p][v]!=a[i+p][j+v])
					{
						fg=0;
					}
				}
			}
			if(fg==1)
			{
				ans=1;
			}
		}
	}
	if(ans==1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 256
/*
author : w2sc
  date : 2019/12/22
  time : 20:17:02
*/
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double EPS=1e-10,PI=acos(-1.);
ll n;
int main()
{
    cin>>n;
    if(n&1ll) return 0*printf("0\n");
    ll ans=0;
    n/=2;
    while(n)
        ans+=n/5,n/=5;
    cout<<ans;
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

vector<int> flag(56010,1);

void init(){
	flag[0] = flag[1] = 0;
	for(int i = 2; i*i <= 56000; i++){
		if(flag[i]){
			for(int j = i+i; j < 56000; j += i) flag[j] = 0;
		}
		
	}
}

int main()
{
	init();
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 0; cnt != n; i++){
		if(flag[i] && i%5 == 1){
			cout << i << ' ';
			cnt++;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int K,count=0;
	cin>>K;
	for(int i=2;i<=K;i+=2){
		for(int j=1;j<=K;j+=2){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

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

int main()
{
  ll a,b,k;
  cin >> a>>b>>k;
  if(a >= k) cout << a - k << " " << b << endl;
  else if(k - a <= b) cout << 0 << " " << b - (k - a) << endl;
  else cout << "0 0" << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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

int main() {
    ll x, k, d; cin >> x >> k >> d;

    ll ans;
    ll X = abs(x);
    if(X/d >= k) ans = X - k*d;
    else{
        k -= X/d;
        if(k%2 == 0)    ans = X - d*(X/d);
        else ans = abs(X - d*(X/d + 1));
    }
    co(ans);

    return 0;
}




Measured memory_bytes: 3620
def solve():
    H, W = map(int, input().split())
    if H == 0:
        return False
    if H*W % 2 == 1:
        print(0)
        return True
    state = [[-1]*W for i in range(H)]
    def dfs(k):
        if k == H*W:
            return 1
        i, j = divmod(k, W)
        if state[i][j] != -1:
            return dfs(k+1)
        if i > 0 and j > 0 and state[i-1][j-1] != state[i-1][j] != state[i][j-1] != state[i-1][j-1]:
            return 0
        r = 0
        state[i][j] = k
        if i+1 < H:
            state[i+1][j] = k
            r += dfs(k+1)
            state[i+1][j] = -1
        if j+1 < W and state[i][j+1] == -1:
            state[i][j+1] = k
            r += dfs(k+1)
            state[i][j+1] = -1
        state[i][j] = -1
        return r
    print(dfs(0))
    return True
while solve():
    ...


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

#define    ll    long long int

const int inf = 1000000000;
const int N = 1e5 + 5;
vector<int> g[N];
vector< pair<int, int> > e;
map< pair<int, int> , int > mp;
int ans = 0;

void dfs(int u, int p, int col)
{
    if (col != inf)   ans = max(ans, col);
    int a, b;
    a = u;
    b = p;
    if (a > b)
        swap(a, b);
    //cout << a << ' ' << b << ' ' << col << '\n';
    mp.insert(make_pair(make_pair(a, b), col));
    int cur = 1;
    for (int i = 0; i < (int) g[u].size( ); i++)
    {
        int v = g[u][i];
        if (v == p) continue;
        if (cur == col) cur++;
        dfs(v, u, cur++);
    }
}

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

    int i, j, k, u, v;
    int n;
    cin >> n;
    for (i = 1; i < n; i++)
    {
        cin >> u >> v;
        e.push_back(make_pair(u, v));
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, -1, 1000000000);
    cout << ans << '\n';
    for (i = 0; i < n - 1; i++)
    {
        u = e[i].first;
        v = e[i].second;
        cout << mp[make_pair(u, v)] << '\n';
    }
    return 0;
}


Measured memory_bytes: 14076
#include<iostream>
using namespace std;
int gcd(int m,int n){
  if(!n)  return m;
  return gcd(n,m%n);
}
int main(){
  int W,H,C;
  cin>>W>>H>>C;
  int gc=gcd(W,H);
  cout<<W/gc*H/gc*C<<endl;
}



Measured memory_bytes: 3084
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>
 
using namespace std;
 
int main() {
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> c(r);
  for(int i = 0; i < r; i++) cin >> c[i];
  for(int i = 0; i < r; i++) --c[i];
  vector<vector<long long>> p(n);
  for(int i = 0; i < n; i++) p[i].resize(n);
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) p[i][j] = 1000000000;
  for(int i = 0; i < m; i++) {
    long long A, B, C;
    cin >> A >> B >> C;
    A--; B--;
    p[A][B] = p[B][A] = C;
  }
 
  for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) p[i][j] = min(p[i][j], p[i][k] + p[k][j]);
 
  long long ans = 1000000000000000;
  long long l = 1;
  for(int i = 1; i <= r; i++) l *= i;
  sort(c.begin(), c.end());
  for(int i = 0; i < l; i++) {
    next_permutation(c.begin(), c.end());
    long long cr = 0;
    for(int i = 1; i < r; i++) cr += p[c[i - 1]][c[i]];
    ans = min(ans, cr);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0; i<N; i++){
   cin>>a[i];
  }
  sort(a.begin(), a.end());
  cout<<a.at(N-1)-a.at(0)<<endl;
  
}

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

int main(void)
{
    int N;
    cin >> N;
    int a[N];
    for( int i = 0; i < N; i++){
        cin >> a[i];
    }
    int min = a[0];
    int max = a[0];
    for( int i = 1; i < N; i++){
        if( min > a[i] ) min = a[i];
        if( max < a[i] ) max = a[i];
    }
    cout << max - min;
}

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int GCD(int x,int y){
    int temp;
    if(x<y){
        temp=x,x=y,y=temp;
    }
    if(y<1){
        return -1;
    }
    if(x%y==0){
        return y;
    }
    return GCD(x,x%y);
}

int main(){
    int N,ans=1;
    string S;
    cin >> N >> S;
    for(int i=1;i<N;i++){
        if(S[i]!=S[i-1])
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
N, M, X = map(int, input().split())
matrix = tuple(tuple(map(int, input().split())) for _ in range(N))
ans = float("inf")
for comb in range(1 << N):
    temp = [0] * (M + 1)
    for i in range(N):
        if comb & (1 << i):
            for m in range(M + 1):
                temp[m] += matrix[i][m]
    if all(temp[i] >= X for i in range(1, M + 1)):
        ans = min(ans, temp[0])
print(-1 if ans == float("inf") else ans)

Measured memory_bytes: 68872
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {
   
int N;
int ans=1;
cin >>N;
string output;

while(ans!=0){
if(N<0){
	ans=(N-(-N%2))/-2;
if(-N%2==0){
output+="0";
}else{
output+="1";
}
}else{
ans=(N-(N%2))/-2;
if(-N%2==0){
output+="0";
}else{
output+="1";
}
}

N=ans;
}	
reverse(output.begin(),output.end());
ce(output)

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 100010
#define inf 1000000007
//#define mod 1000000009
#define inv 500000005
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,int>pii;
typedef bitset<maxn> bit;
typedef long double ld;
ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,siz[maxn];
pii p[maxn];
int head[maxn],nxt[maxn*2],to[maxn*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
int u[maxn],v[maxn];
ll dfs(int x,int las,ll d)
{
    ll res=d;
    for(int i=head[x];i;i=nxt[i])
      if(to[i]!=las)  res+=dfs(to[i],x,d+1);
    return res;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  p[i].fi=read(),p[i].se=i,siz[i]=1;
    sort(p+1,p+n+1);reverse(p+1,p+n+1);
    for(int i=1;i<n;i++)
    {
        int l=1,r=n,pos=0;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(p[mid].fi>=p[i].fi+2*siz[i]-n)
            {
                pos=mid;
                l=mid+1;
            }
            else r=mid-1;
        }
        if(p[pos].fi!=p[i].fi+2*siz[i]-n)  return puts("-1"),0;
        siz[pos]+=siz[i];
        u[i]=p[pos].se;v[i]=p[i].se;
        add(u[i],v[i]);
        add(v[i],u[i]);
    }
    ll com=dfs(p[n].se,0,0);
    if(com!=p[n].fi)   return puts("-1"),0;
    for(int i=1;i<n;i++)  printf("%d %d\n",u[i],v[i]);
    return 0;
}

Measured memory_bytes: 12220
#include<bits/stdc++.h>
using namespace std;
int p[300000055];
int main(){
	long long a,ans=0;
	cin>>a;
	for(int i=0;i<3*a;i++) cin>>p[i];
	sort(p,p+3*a);
	for(int i=3*a-2;i>a-1;i-=2) ans+=p[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
from collections import deque

N, M = map(int, input().split())

graph = [[] for i in range(3*N)]
for i in range(M):
  u, v = map(int, input().split())
  u, v = 3*(u - 1), 3*(v - 1)
  graph[u].append(v+1)
  graph[u+1].append(v+2)
  graph[u+2].append(v)

s, t = map(int, input().split())
s, t = 3*(s - 1), 3*(t - 1)


dist = [10**9] * 3*N
dist[s] = 0
d = deque([s])
while d:
  node = d.popleft()
  children = graph[node]
  for child in children:
    if dist[child] > dist[node] + 1:
      d.append(child)
      dist[child] = dist[node] + 1

if dist[t] < 10**9:
  print(dist[t]//3)
else:
  print(-1)

Measured memory_bytes: 60164
#include <iostream>

using namespace std;

string s, t;
int n, m, ans;

int C(int b) {
  int c = 0;
  for (int i = 0; i < m; i++) {
    c += s[i + b] != t[i];
  }
  return c;
}

int main() {
  cin >> s >> t;
  n = s.length();
  m = t.length();
  ans = m;
  for (int i = 0; i <= n - m; i++) {
    ans = min(ans, C(i));
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    vector<bool> primes(50030);

    for(int i = 0; i < 50030; i++) {
        primes[i] = true;
    }
    primes[0] = false;
    primes[1] = false;

    for(int i = 2; i < 50030; i++) {
        if (primes[i]) {
            for(int k = 2 * i; k < 50030; k+=i) {
                primes[k] = false;
            }
        }
    }

    int n;
    while(cin >> n) {
        for (int i = n - 1; i >= 2; i--) {
            if (primes[i]) {
                cout << i << " ";
                break;
            }
        }

        for (int i = n + 1; i < 50030; i++) {
            if (primes[i]) {
                cout << i << endl;
                break;
            }
        }
    }
     
    return 0;
}

Measured memory_bytes: 0
#include<iostream> 
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if(a < b) {
		cout << "a < b" << endl;
	}
    else {
		cout << "a == b" << endl;
	}
}


Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1),EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll w;
// ll dfs(int now,bool left){
//   if(now == w) return 1LL;
//   ll res = 0;
//   if(left) res += dfs(now+1,true);
//   res += dfs(now+1,false);
//   return res;
// }
signed main(){
  ll h,k;
  cin >> h >> w >> k;
  vvl dp(h+1,vl(w,0LL));
  dp[0][0] = 1;
  REP(i,h)REP(j,w)REP(l,1<<(w-1)){
    bool ng = false;
    REP(x,w-1){
      if(l>>x&l>>(x+1)&1) ng = true;
    }
    if(ng) continue;
    if(j<w-1&&l>>j&1) dp[i+1][j+1]+=dp[i][j],dp[i+1][j+1]%=MOD;
    else if(j>0&&l>>(j-1)&1) dp[i+1][j-1] += dp[i][j],dp[i+1][j-1]%=MOD;
    else dp[i+1][j] += dp[i][j],dp[i+1][j]%=MOD;
  }
  cout << dp[h][k-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

vi lose,back;
vector<double> p,y;
int n,t;

void solve(){
	if(t==0)return;
	auto next=p;
	fill(all(next),0.0);
	auto ny=y;
	fill(all(ny),0.0);
	rep(i,n){
		if(i==n-1){
			next[i]+=p[i];
			continue;
		}
		rep(j,6){
			int pos=i+j+1;
			if(pos>=n)pos=n-1-(pos-n+1);
			if(find(all(lose),pos)!=lose.end()){
				ny[pos]+=p[i]/6;
			}else if(find(all(back),pos)!=back.end()){
				next[0]+=p[i]/6;
			}else{
				next[pos]+=p[i]/6;
			}
		}
	}
	rep(i,n) next[i]+=y[i];
	y=ny;
	p=next;
	t--;
	solve();
}



int main(){
	int l,b;
	while(cin>>n>>t>>l>>b,n){
		n++;
		p.resize(n);
		fill(all(p),0.0);
		y.resize(n);
		fill(all(y),0.0);
		p[0]=1.0;
		lose.resize(l);
		back.resize(b);
		for(auto&i:lose)cin>>i;
		for(auto&i:back)cin>>i;
		solve();
		cout.precision(6);
		cout<<fixed<<p[n-1]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3336
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int N = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		int[] H = new int[N+1];
		for(int h=1; h<N+1; h++) {
			H[h] = keyboard.nextInt();
		}
		
		int[] Win = new int[N+1];
		//配列に初期値をセットする。初期値の1なら他の展望台よりも高い状態である
		Arrays.fill(Win, 1);
		
		for(int a=0; a<M; a++) {
			int aL = keyboard.nextInt();
			int bR = keyboard.nextInt();
			
			if(H[aL] > H[bR]) {
				if(Win[aL] == 1) {
					Win[aL] = 1;
				}
				Win[bR] = 0;
			}
			
			if(H[aL] < H[bR]) {
				if(Win[bR] == 1) {
					Win[bR] = 1;
				}
				Win[aL] = 0;
			}
			
			if(H[aL] == H[bR]) {
				Win[bR] = 0;
				Win[aL] = 0;
			}
		}
		
		int ans = 0;
		for(int w = 1; w<N+1; w++) {
			if(Win[w] == 1) {
				ans++;
			}
		}
		
		System.out.println(ans);
		keyboard.close();
	}
}


Measured memory_bytes: 60184
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cstdio>
#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
using namespace std;
int main()
{
	string str; while (getline(cin, str) && str[0] != '.' && str.size() != 1)
	{
		int id = 0;
		stack<int> stck;
		rep(i, (int)str.size())
		{
			switch (str[i])
			{
				case '(':	stck.push(1);	break;
				case '[': stck.push(2); break;
				case ')': 
					if (stck.size() == 0) { id = 1; }
					else if (stck.top() == 1) { stck.pop(); }
					else { id = 1; } break;
				case ']': 
					if (stck.size() == 0) { id = 1; }
					else if (stck.top() == 2) { stck.pop(); }
					else { id = 1; } break;
			}
		}
		if (stck.size() != 0 || id == 1) { printf("no\n"); }
		else { printf("yes\n"); }
	}
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define  pb push_back
#define nl "\n"
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
int dp[1234][1234];
string s[1234];
int main()
{
	fastScan;
	int h,w;cin>>h>>w;
	int mod=(int)(1e9+7);
	for(int i=0;i<h;i++)
		cin>>s[i];
	dp[1][1]=1;
	int fl=1;
	for(int i=2;i<=w;i++)
	{
		if(s[0][i-1]=='#')
			fl=0;
		dp[1][i]=fl;
	}
	fl=1;
	for(int i=2;i<=h;i++)
	{
		if(s[i-1][0]=='#')
			fl=0;
		dp[i][1]=fl;
	}
	for(int i=2;i<=h;i++)
	{
		for(int j=2;j<=w;j++)
		{
			if(s[i-1][j-1]=='#')
				dp[i][j]=0;
			else
				dp[i][j]=(dp[i][j-1]%mod+dp[i-1][j]%mod)%mod;
		}
	}
	cout<<dp[h][w]<<nl;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<x<<endl;
#define ya cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
typedef unsigned long long ll;
using namespace std;
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    //freopen("test.txt","r",stdin);

        ll ans=1;
        long double n,m,a;
        cin>>n>>m;
        //scanf("%lf %lf",&n,&m);
        a=1.0*n*m;
        ans=a;
        //ans=1.0*n*m*1.0;
        //printf("%lld\n",ans);
cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3728
N = int(input())
A = list(map(int,input().split()))
CSum=[[0 for i in range(N+1)] for j in range(21)]

for i in range(1,N+1):
    nowA = A[i-1]
    for j in range(21):
        CSum[j][i] = CSum[j][i-1]
        CSum[j][i] += nowA%2
        nowA //= 2

l = 0
r = 1
ans = 0
while r <= N :
    ok = True
    for i in range(21):
        if CSum[i][r] - CSum[i][l] >= 2:
            ok = False
    
    if ok:
        ans += r-l
        r += 1
    else:
        l += 1

print(ans)


Measured memory_bytes: 136584
#include <stdio.h>
int main () 
{
    char s[110];
    int a,b;

scanf("%s",&s);

for(a=0;s[a]!='\0';a++);

for(b=0;b<a;b++)
{
    s[b]='x';
}

printf("%s",s);
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
		while (!line.equals(".")) {
			Stack<Character> stack = new Stack<>();
			boolean yes = true;
			for (int i = 0; i < line.length(); i++) {
				char c = line.charAt(i);
				if (c == '(' || c == '[') {
					stack.push(Character.valueOf(c));
				} else if (c == ')' || c == ']') {
					if (stack.isEmpty()) {
						yes = false;
						break;
					}
					char c0 = stack.pop().charValue();
					if (c == ')' && c0 != '(') {
						yes = false;
						break;
					}
					if (c == ']' && c0 != '[') {
						yes = false;
						break;
					}
				} else if (c == '.') {
					break;
				}
			}
			if (yes) {
				if (!stack.isEmpty()) yes = false;
			}
			System.out.println(yes ? "yes": "no");
	        line = scanner.nextLine();
		}
	}
}



Measured memory_bytes: 45564
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

const int N=200005;

int n;
ll ans;
int a[N];

int main(){
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	if (a[1]){
		printf("-1\n");
		return 0;
	}
	for (i=2;i<=n;i++) if (a[i]-a[i-1]>1){
		printf("-1\n");
		return 0;
	}
	for (i=n;i>1;i=j-1){
		j=i;
		if (!a[i]) continue;
		while (j>1&&a[j]==a[j-1]+1) j--;
		ans+=1ll*a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

#include<string>
#include <bits/stdc++.h>
using namespace std;

int main(){
  int k,a,b;
  cin >> k;
  cin >> a >> b;
  int i=0,flag=0;
  for(i=0;i<=b-a;i++){
    if((a+i)%k == 0){
      cout << "OK" << endl;
      flag=1;
      break;
    }
  }
  if(flag==0){
    cout << "NG" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
    int n,m; cin >> n >> m;
    UnionFind tree(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        tree.unite(a-1,b-1);
    }
    int cnt=0;
    rep(i,n){
        if(tree.par[i] == i) cnt++;
    }
    cout << cnt - 1  << endl;

}

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

int g[15][15];

int main() {
    int n;
    cin >> n;
    rep(i,n)rep(j,n) g[i][j] = -1;
    rep(i,n){
        int m;
        cin >> m;
        rep(j,m){
            int a, x;
            cin >> a >> x;
            --a;
            g[i][a] = x;
        }
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n) if(i>>j&1){
            d[j] = 1;
        }
        bool ok = true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  if(n%2==0){
    cout << n << endl;
  }else{
    cout << n*2 << endl;
   }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] x = new double[n];
        double[] y = new double[n];
        for(int i = 0; i < n; i++){
            x[i] = sc.nextDouble();
        }
        for(int i = 0; i < n; i++){
            y[i] = sc.nextDouble();
        }
        double[] result = new double[4];
        for(int i = 0; i < 4; i++){
            result[i] = 0.0;
        }
        for(int i = 0; i < n; i++){
            double sub = Math.abs(x[i] - y[i]);
            result[0] += sub;
            result[1] += Math.pow(sub, 2.0);
            result[2] += Math.pow(sub, 3.0);
            result[3] = Math.max(result[3], sub);
        }
        result[1] = Math.pow(result[1], 1.0 / 2.0);
        result[2] = Math.pow(result[2], 1.0 / 3.0);

        for(int i = 0; i < 4; i++){
            System.out.println(result[i]);
        }
    }
}



Measured memory_bytes: 28936
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=(a)&&(a)<b)
#define INF 1<<30
using namespace std;
int dx[]={-1,1,0,0},dy[]={0,0,-1,1};
int x[11],y[11],d[11][11],w,h,n; char r[21][21];
int dfs(int cy,int cx,int gy,int gx,int c[21][21]){
	int ans=INF;
	rep(d,4){
		int ty=cy+dy[d],tx=cx+dx[d];
		if(!ck(ty,h)||!ck(tx,w)||r[ty][tx]=='x')continue;
		if(c[ty][tx]>c[cy][cx]+1){
			c[ty][tx]=c[cy][cx]+1;
			if(ty==gy&&tx==gx)return c[ty][tx];
			ans=min(ans,dfs(ty,tx,gy,gx,c));
		}
	}
	return ans;
}
int main(){
	while(cin>>w>>h,w){
		n=1;
		rep(i,h)rep(j,w){
			cin>>r[i][j];
			if(r[i][j]=='o')y[0]=i,x[0]=j;
			if(r[i][j]=='*')y[n]=i,x[n]=j,n++;
		}
		rep(i,n)rep(j,i){
			int c[21][21]; rep(k,21)rep(l,21)c[k][l]=INF;
			c[y[i]][x[i]]=0;
			d[i][j]=d[j][i]=dfs(y[i],x[i],y[j],x[j],c);
		}
		queue<pair<int,int> > F; int cost[1<<n][n];
		F.push(make_pair(1,0)); rep(i,1<<n)rep(j,n)cost[i][j]=INF;
		cost[1][0]=0;
		while(!F.empty()){
			int cs=F.front().first,ns,ct=F.front().second; F.pop();
			rep(i,n){
				if(cs&(1<<i))continue;
				ns=cs|(1<<i);
				if(cost[ns][i]>cost[cs][ct]+d[ct][i])
				F.push(make_pair(ns,i)),cost[ns][i]=cost[cs][ct]+d[ct][i];
			}
		}
		int ans=INF;
		rep(i,n)if(ans>cost[(1<<n)-1][i])ans=cost[(1<<n)-1][i];
		cout<<(ans==INF?-1:ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 960
S = input()
#N = int(input())
#A, B = map(int, input().split())
#List = list(map(int, input().split()))
 
if S=="RRR":
    print(3)
elif S=="RRS":
    print(2)
elif S=="SRR":
    print(2)
elif S=="SSS":
    print(0)
else:
    print(1)

Measured memory_bytes: 9032
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 200123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define oo 1000000123
#define sz(x) ((int)((x).size()))
#define pi acos(-1)

using namespace std;

int n, v[N];

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i < n; ++i){
        int x;
        cin >> x;
        v[x]++;
    }
    for(int i = 1; i <= n; ++i) cout << v[i] << '\n';
    return 0;
}


Measured memory_bytes: 4360
import math
A,B,H,M = map(int, input().split())
kaku = 0

if H <=6 and M<=30:
    a = H*30+30*M/60
    b = M*6
    kaku = max(a,b) - min(a,b)
elif H<=6 and M > 30:
    a = H*30+30*M/60
    b = (60-M)*6
    c = M*6
    kaku = min(a+b, c-a)
elif H>6 and M<=30:
    a = H*30+30*M/60
    b = M*6
    c = (12-H)*30-30*M/60
    kaku = min(c+b, a-b)
else:
    a = (12-H)*30-30*M/60
    b = (60-M)*6
    kaku = max(a,b) - min(a,b)

kaku = math.radians(kaku)
a = (A*A + B*B - 2*A*B*math.cos(kaku))**(1/2)
print(a)

Measured memory_bytes: 9628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 600000;
const int K = 1000000000;
int a[N], b[N];
int read(){
    string s;
    cin >> s;
    if (s == "Vacant") exit(0);
    return (s == "Male");
}
int solve(int l, int r, int x){
    int mid = (r + l) / 2;
    cout << mid << endl;
    fflush(stdout);
    int y = read();
    int len = mid - l;
    if (x == y && len % 2 == 1 || x != y && len % 2 == 0){
        solve(mid + 1, r, y);
    } else{
        solve(l, mid - 1, x);
    }
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n;
    cin >> n;
    cout << "0" << endl;
    fflush(stdout);
    int x = read();
    solve(1, n - 1, x);
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=1001 ;
int main()
{
   fast ;
   ll n,d,a ;
   cin>>n>>d>>a ;

   vector<pll>v ;
   for(ll i=0;i<n;i++)
   {
       ll a,b ;
       cin>>a>>b ;
       v.pb({a,b}) ;
   }
   sort(all(v)) ;

   vector<ll>x ;
   for(ll i=0;i<n;i++)
   {
       x.pb(v[i].ff) ;
   }
   ll p=0 ;
   vector<ll>aux(n,0) ;
   ll ans=0 ;
   for(ll i=0;i<n;i++)
   {
       ll xx=v[i].ss ;
       p+=aux[i] ;
       xx+=p ;
       if(xx>0)
       {
           ll st=v[i].ff+d ;
           ll ed=st+d ;
           ll y=xx/a ;
           if(xx%a!=0)
            y++ ;


           auto it=upper_bound(all(x),ed) ;

           if(it!=x.end())
           {
               ll ind=(ll)(it-x.begin()) ;
               aux[ind]+=y*a ;


           }
           ans+=y ;
           p-=y*a ;

       }
   }



   cout<<ans ;



}


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

typedef long long int int64;

typedef struct indexVal{
  int64 val;
  int index;
} node;

typedef node dequeval;

typedef struct deque {
  dequeval *array;
  size_t front;
  size_t last;
  size_t mask;
} deque;

deque* newDeque(void){
  const int len=2;
  deque *d=(deque *)calloc(len,sizeof(dequeval));
  d->array=(dequeval *)calloc(len,sizeof(dequeval));
  d->front=d->last=0;
  d->mask=len-1;
  return d;
}

void initDeque(deque *d){
  d->front=d->last=0;
}

void freeDeque(deque *d){
  free(d->array);
  free(d);
}

int isEmpty(deque *d){
  return d->front==d->last;
}

void deque_realloc(deque *d){
  dequeval *array=(dequeval *)calloc(2*(d->mask+1),sizeof(dequeval));
  size_t k=0;
  for(size_t i=d->front;i!=d->last;i=(i+1)&d->mask) array[k++]=d->array[i];
  free(d->array);
  d->array=array;
  d->front=0;
  d->last=k;
  d->mask=2*d->mask+1;
}

dequeval pop_front(deque *d){
  dequeval res=d->array[d->front];
  d->front=(d->front+1)&d->mask;
  return res;
}

dequeval pop_back(deque *d){
  d->last=(d->last+d->mask)&d->mask;
  return d->array[d->last];
}

dequeval get_front(deque *d){
  return d->array[d->front];
}

dequeval get_back(deque *d){
  return d->array[(d->last+d->mask)&d->mask];
}

void push_front(deque *d,dequeval v){
  if(((d->last+1)&d->mask)==d->front){
    deque_realloc(d);
  }
  d->front=(d->front+d->mask)&d->mask;
  d->array[d->front]=v;
}

void push_back(deque *d,dequeval v){
  if(((d->last+1)&d->mask)==d->front){
    deque_realloc(d);
  }
  d->array[d->last]=v;
  d->last=(d->last+1)&d->mask;
}

void run(void){
  int n,m,k;
  scanf("%d%d%d",&n,&m,&k);
  int *a=(int *)calloc(n+1,sizeof(int));
  int i;
  for(i=1;i<=n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc(n+1,sizeof(int64));
  deque *deq=newDeque();
  for(i=1;i<=k;i++){
    initDeque(deq);
    push_back(deq,(node){dp[i-1],i-1});
    for(int j=i;j<=n;j++){
      node t=get_front(deq);
      if(t.index<j-m){
	pop_front(deq);
	t=get_front(deq);
      }
      int64 local=(int64)i*a[j]+t.val;
      while(!isEmpty(deq)){
	t=get_back(deq);
	if(t.val>dp[j]) break;
	pop_back(deq);
      }
      push_back(deq,(node){dp[j],j});
      dp[j]=local;
    }
  }
  int64 ans=0;
  for(i=k;i<=n;i++) if(ans<dp[i]) ans=dp[i];
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
 
int main(){
  unsigned short *A, *B;
 
  int C[10000+1], i, n;

  scanf("%d", &n);
 
  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);
 
  for(i = 0; i <= 10000; i++) 
		C[i] = 0;
 
  for(i = 0; i < n; i++){
    scanf("%d", &A[i + 1]);
    C[A[ i + 1]]++;
  }
 
  for(i = 1; i <= 10000; i++)
		C[i] = C[i] + C[i - 1];
 
  for(i = 1; i <= n; i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
 
  for(i = 1; i <= n; i++){
    if( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }

  printf("\n");
 
  return 0;
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define endl        "\n"
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vi ,greater< int >>
#define INF         1e18

using namespace std;

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


signed main()
{
    showoff;
    string s;
    cin >> s;
    int ans = mod;
    FOR(i,0,sz(s)-2){
    int n = 100*(s[i]-'0')+10*(s[i+1]-'0')+s[i+2]-'0';
    ans = min(ans,llabs(753-n));
    }
    cout << ans;
    /*int fa = 0;
    for(int i=2;i*i <= n;++i)
    if(n%i == 0)fa = i;
    if(fa == 0){cout << "NO\n";return 0;}
    cout << "YES\n";
    */
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ll INF = 1e15;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b == 1) {
		return a;
	}
	ll ans = pow(a, b / 2);
	ans *= ans;
	ans *= b % 2 == 1 ? a : 1;
	return ans;
}

namespace SOLVE {
	vector<VI> edges;
	vector<VI> ans;
	VI lowlink;
	VI visited;
	VI firstvisit;
	int time = 0;
	int children = 0;

	void dfs(int at, int previous) {
		firstvisit[at] = time;
		lowlink[at] = time;
		time++;

		visited[at] = 1;
		if (previous == 0) {
			children++;
		}


		for (int to : edges[at]) {
			if (!visited[to]) {
				dfs(to, at);
				lowlink[at] = min(lowlink[at], lowlink[to]);
				
				if (lowlink[to] > firstvisit[at]) {
					ans[min(at, to)].push_back(max(at, to));
				}
			}
			else {
				if (to != previous) {
					lowlink[at] = min(lowlink[at], firstvisit[to]);
				}
			}
		}
	}

	void main() {
		int n, m, a, b;
		cin >> n >> m;
		ans.resize(n);
		edges.resize(n);
		REP(i, 0, m) {
			cin >> a >> b;
			edges[a].push_back(b);
			edges[b].push_back(a);
		}
		firstvisit.resize(n);
		lowlink.resize(n);
		visited.resize(n);
		ans.resize(n);

		dfs(0, -1);

		REP(i, 0, n) {
			sort(ans[i].begin(), ans[i].end());
			REP(j, 0, sz(ans[i])) {
				cout << i << ' ' << ans[i][j] << endl;
			}
		}

	}
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}



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

using namespace std;
using ll = long long;

int solve(int k)
{
    ll n = 7;
    for (ll i = 1; i <= k; ++i)
    {
        ll m = n % k;
        if (m == 0)
            return i;
        n = n * 10 + 7;
        n %= k;
    }

    return -1;
}

int main(void)
{
    int k;
    cin >> k;
    cout << solve(k) << endl;

    return 0;
}


Measured memory_bytes: 3588