akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int x,y,z,a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if (a > b) a = b;
	if (c > d) c = d;
	printf("%d",a+c);
	return 0;
}

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

int main () {
  int N, A;
  cin >> N >> A;
  
  int check = 0;
  check = N % 500;
  
  if (A >= check) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        double[] A = new double[N];
        var input = Console.ReadLine().Split();
        double sum = 0;
        for(int i=0; i < N; i++)
        {
            A[i] = double.Parse(input[i]);
            sum += 1 / A[i];
        }
        Console.WriteLine(1 / sum);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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

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

ll GCD(ll m, ll n) {
   if (m == 0) {
     return n;
   } 
   if (n == 0) {
     return m;
   }
 
   if (m >= n) {
     return GCD(m%n, n);
   } else {
     return GCD(m, n%m);
   }
 }


int N;
ll a[110000];

int main () {
  cin >> N;
  rep(i, N) cin >> a[i];

  ll tmp = a[1];

  for (int i=2;i<=N;++i) {
    tmp = GCD(tmp, a[i]);
  }

  cout << tmp << "\n";
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int f(int x){
	return x*x;
}

int main(void){
	int d;
	while(cin >> d){
		int s=0;
		for(int i=0;i<600;i+=d){
			s += f(i)*d;
		}
		cout << s <<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N, M, K, tmp;
  vector<ll> A;
  vector<ll> B;
  
  cin >> N >> M >> K;
  rep(i,N){
    cin >> tmp;
    A.push_back(tmp);
  }
  rep(i,M){
    cin >> tmp;
    B.push_back(tmp);
  }
  ll cnt = 0;
  
  ll ruia[200010]={};
  ll ruib[200010]={};
  
  ruia[0] = A[0];
  rep(i,N-1){
    ruia[i+1] = ruia[i] + A[i+1];
  }
  ruib[0] = B[0];
  rep(i,M-1){
    ruib[i+1] = ruib[i] + B[i+1];
  }
  
  auto IterA = upper_bound(ruia, ruia+N, K);
  //auto IterB = upper_bound(ruib, ruib+M, K);
  ll am, bm;
  am = IterA - ruia;
  //bm = IterB - ruib;
  
  rep(i, am){
    ll zan = K-ruia[i];
    auto IterT = upper_bound(ruib, ruib+M, zan);
    bm = IterT - ruib;
    cnt = max(cnt, i+1+bm);    
  }
  auto IterT = upper_bound(ruib, ruib+M, K);
  bm = IterT - ruib;
  cnt = max(cnt, bm);
  
  cout << cnt << endl;
  
}

Measured memory_bytes: 9820
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define x first
#define y second

namespace gwlthll
{
	typedef long long ll;
	typedef std::pair<int,int> pii;
	const int N=101000,INF=1000000007;
	ll sa[N],sb[N];
	pii s[N];
	int n,L,T,na,nb;

	bool cmp(pii A,pii B){return A.x==B.x?A.y<B.y:A.x<B.x;}

	void initialize()
	{
		scanf("%d%d%d",&n,&L,&T),na=nb=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&s[i].x,&s[i].y);s[i].y=3-s[i].y*2;
			if(s[i].y==1)sa[++na]=s[i].x;
			else sb[++nb]=s[i].x;
		}
	}
	inline int adj(int x){return (x%L+L)%L;}
	pii GetTheFirstPosition()
	{
		if(!na || !nb)return pii(adj(s[1].x+s[1].y*T),s[1].y);
		int ia,ib,k=s[1].y,rt=T*2;
		if(k>0)
		{
			ia=1,ib=1,k*=-1;
			rt-=sb[1]-sa[1];
		}
		else
		{
			ia=na,ib=1,k*=-1;
			rt-=adj(sb[1]-sa[na]);
		}
		if(rt<0)return pii(adj(s[1].x+s[1].y*T),s[1].y);

//		printf("%d\n",rt);
//		printf("%lld\n",(ll)na*nb*L);
		rt=(ll)rt%((ll)na*nb*L);
//		printf("%d\n",rt);

		while(1)
		{
			ll nt=L,tmp=na%nb;
			int tb=(ib-1+tmp)%nb+1,fk;
			nt+=(ll)L*(na/nb);
			fk=sb[tb]-sb[ib];if(fk<0)fk+=L;
			nt+=fk;
			
			if(rt>=nt)rt-=nt,ib=tb;
			else break;
		}

		while(1)
		{
//			printf("%d %d %d %d\n",ia,ib,k,rt);
			if(k>0)
			{
				int tb=ib%nb+1,nt=(sb[tb]-sb[ib]);
				if(nt<=0)nt+=L;
				if(rt<nt)break;
				rt-=nt,ib=tb;
			}
			else 
			{
				int ta=((ia-2+na*2)%na)+1,nt=(sa[ia]-sa[ta]);
				if(nt<=0)nt+=L;
				if(rt<nt)break;
				rt-=nt,ia=ta;
			}
//			printf("?\n");
			k*=-1;
		}

//		printf("%d %d %d %d\n",ia,ib,k,rt);
		
		int pos;
		
		if(k>0)pos=sa[ia];
		else pos=sb[ib];
		pos=adj(pos+k*T);

		return pii(pos,k);
	}
	void solve()
	{
		initialize();
		pii A=GetTheFirstPosition();

		for(int i=1;i<=n;i++)
			s[i].x=((s[i].x+T*s[i].y)%L+L)%L;
		std::sort(s+1,s+n+1,cmp);

		int pos=0;
		for(int i=1;i<=n;i++)
			if(s[i]==A){pos=i;break;}

		for(int cnt=n;cnt--;)
		{
			printf("%d\n",s[pos].x);
			pos=pos%n+1;
		}
	}
}

int main()
{
//	freopen("C.in","r",stdin);
//	freopen("C.out","w",stdout);
	gwlthll::solve();
	return 0;
}


Measured memory_bytes: 2816
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int bit = 0;
    for (int i=0; i<N; i++){
      bit |= sc.nextInt();
    }
    System.out.println(Integer.numberOfTrailingZeros(bit));
  }
}

Measured memory_bytes: 23764
fn main() {
    let scan = std::io::stdin();

    let mut line = String::new();

    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let n: u32 = vec[0].parse().unwrap_or(0);

    let h: u32 = &n / 3600;
    let m: u32 = (&n / 60) % 60;
    let s: u32 = &n % 60;

    println!("{}:{}:{}", h,m,s);
}


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


int main() {

    vector<int> v(3);
    rep(i,3) cin >> v[i];
    sort(v.begin(), v.end());
    cout << v[0] + v[1] << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,k = map(int,input().split())
a = [0]*m
b = [0]*m
c = [0]*k
d = [0]*k
for i in range(m):
    a[i],b[i] = map(int,input().split())
for i in range(k):
    c[i],d[i] = map(int,input().split())

class UnionFind:

    def __init__(self, n):
        self.par =  [-1] * n
        self.rank = [0] * n
    
    def root(self,x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return
        if self.rank[x] <self.rank[y]:
            self.par[y] += self.par[x] #負+負でsize管理 
            self.par[x] = y
        else:
            self.par[x] += self.par[y]
            self.par[y] = x
            if self.rank[x] == self.rank[y]: #負+負でsize管理 
                self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

friend = [[]*(n+1) for i in range(n+1)]
for i in range(m):
    friend[a[i]].append(b[i])

block = [[]*(n+1) for i in range(n+1)]
for i in range(k):
    block[c[i]].append(d[i])
    block[d[i]].append(c[i])

Tree = UnionFind(n)

for i in range(1,len(friend)):
    for j in friend[i]:
        Tree.union(i-1,j-1)

for i in range(m):
    friend[b[i]].append(a[i])

ans = [0]*n

for i in range(n):
    s = Tree.size(i)
    s -= len(friend[i+1]) #既に友達
    for j in block[i+1]:
        if Tree.is_same(i,j-1): #ブロックされてる
            s -= 1

    ans[i] = s-1

print(*ans)

Measured memory_bytes: 124376
/*  ex3_2
    Graku   */
#include <stdio.h>

int main(void) {
    int num; //declaration
    scanf("%d", &num);

    switch (num % 10) { //ones place == num % 10
        case 0 : printf("pon\n"); break;
        case 1 : printf("pon\n"); break;
        case 2 : printf("hon\n"); break;
        case 3 : printf("bon\n"); break;
        case 4 : printf("hon\n"); break;
        case 5 : printf("hon\n"); break;
        case 6 : printf("pon\n"); break;
        case 7 : printf("hon\n"); break;
        case 8 : printf("pon\n"); break;
        case 9 : printf("hon\n"); break;
    }

    return 0;
}


Measured memory_bytes: 1632
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=1;i<=b;i++){
        //printf("%d ",i);
        if(a*i%b==c){
            printf("YES");
            return 0;
        }
    }
    printf("NO");
}


Measured memory_bytes: 1688
al = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
N = int(input())
tmp = 26
ans = ''
while True:
    ans += al[N%26-1]
    if N <= 26:
        break
    if N % 26 == 0:
        N = (N//tmp)-1
    else:
        N = N // tmp
print(ans[::-1])

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

vector <pair <int, int> > edges[100000][3];
int d[100000][3];
bool decided[100000][3];

void dijikstra(int S, int T, int N){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            d[i][j] = INT_MAX;
        }
    }

    priority_queue < pair <int, pair<int, int> > , vector <pair <int, pair<int, int> > >, greater<pair <int, pair<int, int> > > > pq;
    d[S][0] = 0;
    pq.push(make_pair(0, make_pair(S, 0)));
    while(!pq.empty()){
        auto cur = pq.top();
        auto cur_cost = cur.first;
        auto cur_node = cur.second.first;
        auto cur_mod = cur.second.second;
        pq.pop();
        if(d[cur_node][cur_mod] < cur_cost){
            continue;
        }
        for(int i = 0; i < edges[cur_node][cur_mod].size(); i++){
            auto nex = edges[cur_node][cur_mod][i];
            auto next_node = nex.first;
            auto next_mod = nex.second;
            int next_d = d[cur_node][cur_mod] + 1;
            if(d[next_node][next_mod] > next_d){
                d[next_node][next_mod] = next_d;
                pq.push(make_pair(next_d, make_pair(next_node, next_mod)));
            }
        }
    }
}

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

   for(int i = 0; i < M; i++){
       int u;
       int v;
       cin >> u >> v;
       for(int i = 0; i < 3; i++){
           edges[u - 1][i].push_back(make_pair(v - 1, (i + 1) % 3));
           //edges[v - 1][i].push_back(make_pair(u - 1, (i + 1) % 3));
       }
   }

   int S;
   int T;
   cin >> S >> T;

   dijikstra(S - 1, T - 1, N);
   if(d[T - 1][0] == INT_MAX){
       cout << - 1 << endl;
   } else {
    cout << d[T - 1][0] / 3 << endl;
   }

    /*
   for(int i = 0; i < N; i++){
       for(int j = 0; j < 3; j++){
           cout << d[i][j] / 3 << " ";
       }
       cout << endl;
   }
   */
   return 0;
}


Measured memory_bytes: 17792
#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 day=86400;
int num[86400*2];

int main(void){
	int n;
	cin >> n;
	int cur=0;

	rep(i,n){
		int a,b;
		cin >> a >> b;
		cur=(cur+a)%day;
		num[cur]++;
		cur=(cur+b)%day;
	}

	rep(i,day) num[i+day]=num[i];
	rep(i,2*day-1) num[i+1]+=num[i];

	int ans=0;
	const int tar=10800;
	rep(i,1,day) chmax(ans,num[i+tar]-num[i-1]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 1e8;
bool isPrime(ll x)
{
    if(x % 2 == 0) return false;
    for(ll i = 3; i * i <= x; i += 2) if(x % i == 0) return false;
    return true;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    vector<ll> prime;
    prime.push_back(2);
    for(ll x = 3; prime.size() < 10010; x += 2) if(isPrime(x)) prime.push_back(x);
    vector<ll> sum(10010, 0);
    for(int i = 1; i < 10010; i++) sum[i] += sum[i - 1] + (ll)prime[i - 1];
    while(cin >> n, n)
    {
        cout << sum[n] << endl;
    }
    return 0;
}




Measured memory_bytes: 3136
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;
 
    UnionFind (int n = 1 ) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n); siz.resize(n);
        for (int i = 0; i < n; i++) par[i] = i, rank[i] = 0, siz[i] = 1;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool same(int x, int y) {
        return root(x) == root(y);
    }
 
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
 
        if (rank[x] < rank[y]) {
            par[x] = y;
            siz[y] += siz[x];
        }
        else {
            par[y] = x;
            siz[x] += siz[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
 
    int size(int x) {
        return siz[root(x)];
    }
};

//--------------------------- Solve ---------------------------//

void solve() {
    int N, M; cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        uf.unite(a, b);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans = max(ans, uf.size(i));
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 5572
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,d:usize,
    }
    // 2*d + 1 本いける
    let waru = 2 * d + 1;
    println!("{}", (n + waru - 1) / waru);
}


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


#define SIZE 200005

struct Info{
	Info(int arg_value,int arg_loc){
		value = arg_value;
		loc = arg_loc;
	}
	bool operator<(const struct Info &arg) const{

		return value < arg.value;
	}

	int value,loc;
};

int N;
int table[SIZE];

int main(){

	scanf("%d",&N);

	vector<Info> V;
	int tmp;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		V.push_back(Info(tmp,i));
	}

	sort(V.begin(),V.end());

	for(int i = 0; i < V.size(); i++){

		table[V[i].loc] = i;
	}

	for(int i = 0; i < N; i++){

		if(table[i] < N/2){

			printf("%d\n",V[N/2].value);

		}else{

			printf("%d\n",V[N/2-1].value);
		}
	}

	return 0;
}


Measured memory_bytes: 5612
import java.util.Scanner;
public class Main{
  public static void main(String[] arsgs){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    String ans = "APPROVED";
    for (int i = 0; i < n; i++){
      a[i] = Integer.parseInt(sc.next());
    }
    for(int i  = 0; i < n; i++){
      if((a[i]%3 != 0) && (a[i]%5 != 0) &&(a[i]%2 == 0)){
        ans = "DENIED";
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAXN = 200000;

ll N, maxs=0, maxi=0;
vector<ll> A(MAXN, 0), ans(MAXN, 0);
vector<vector<pair<ll, ll>>> G;

void bfs() {
    queue<pair<ll, ll>> Q;
    vector<ll> color(N, 0);
    color[maxi]=1;
    for(int i=0;i<G[maxi].size();i++) {
        Q.push(make_pair(G[maxi][i].first, i));
        color[G[maxi][i].first]=1;
        ans[G[maxi][i].second] = i;
    }
    while(!Q.empty()) {
        pair<ll, ll> p = Q.front();
        Q.pop();
        int c=0;
        for(int i=0;i<G[p.first].size();i++) {
            if(color[G[p.first][i].first]==0) {
                if(c==p.second) c++;
                Q.push(make_pair(G[p.first][i].first, c));
                color[G[p.first][i].first]=1;
                ans[G[p.first][i].second] = c;
                c++;
            }
        }
    }
}

signed main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N-1;i++) {
        ll s, g;
        cin >> s >> g;
        s--;
        g--;
        G[s].push_back(make_pair(g, i));
        G[g].push_back(make_pair(s, i));
    }
    for(int i=0;i<N;i++) {
        if(maxs<G[i].size()) {
            maxs = G[i].size();
            maxi = i;
        }
    }
    bfs();
    cout << maxs << endl;
    for(int i=0;i<N-1;i++) {
        cout << ans[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 11904
K = gets.to_i
７ = [
	[],
	[7,6,5,4,3,2,1,0,9,8],
	[],
	[9,2,5,8,1,4,7,0,3,6],
	[],
	[],
	[],
	[1,8,5,2,9,6,3,0,7,4],
	[],
	[3,4,5,6,7,8,9,0,1,2]
][K%10].map!{|_|_*K}
if ７.empty?
	p(-1)
	exit
end

n = 0
k = ７[0]
while 0<k
	n += 1
	k += ７[k%10]
	k /= 10
end
p n


Measured memory_bytes: 14508
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int row = in.nextInt();
        final int col = in.nextInt();
        final int k = in.nextInt();
        in.nextLine();
        final char[][] g = new char[row][col];
        for (int i = 0; i < row; i++) {
            g[i] = in.nextLine().toCharArray();
        }
        int ans = 0;
        for (int mask = 0; mask < 1 << (row + col); mask++) {
            int count = 0;
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) {
                    if (g[i][j] != '#') { continue; }
                    if ((mask & ((1 << i) | (1 << (row + j)))) != 0) { continue; }
                    count++;
                }
            }
            if (count == k) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35888
n, m = map(int, input().split())
if m == 0:
    print(0)
    exit()

res_111 = []
res_110 = []
res_101 = []
res_100 = []
res_011 = []
res_010 = []
res_001 = []
res_000 = []

for i in range(n):
    x, y, z = map(int, input().split())
    res_111.append(x+y+z)
    res_110.append(x+y-z)
    res_101.append(x-y+z)
    res_100.append(x-y-z)
    res_011.append(-x+y+z)
    res_010.append(-x+y-z)
    res_001.append(-x-y+z)
    res_000.append(-x-y-z)

res_111.sort()
res_110.sort()
res_101.sort()
res_100.sort()
res_011.sort()
res_010.sort()
res_001.sort()
res_000.sort()

print(max(sum(res_111[-m:]),sum(res_110[-m:]),sum(res_101[-m:]),sum(res_100[-m:]),sum(res_011[-m:]),sum(res_010[-m:]),sum(res_001[-m:]),sum(res_000[-m:])))

Measured memory_bytes: 9316
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;


int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif

        ll n;
        cin >> n;
        vector<ll> h(n);
        rep(i, n) cin >> h[i];
        ll dp[n + 10]; // nに到達するまでの最小コスト
        rep(i, n) dp[i] = inf;
        dp[0] = 0;
        rep(i, n) {
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
        }
        cout << dp[n - 1] << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1792
s = [0 for _ in range(int(10e5) + 1)]

n,m = map(int,input().split())

for _ in range(m):
  l,r = map(int,input().split())


  s[l] += 1
  s[r+1] -= 1

ans = 0

for i in range(1,int(1e5)+1):
  s[i] = s[i-1] + s[i]

  if s[i] == m:
    ans += 1
print(ans)



Measured memory_bytes: 14104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define MOD                 1000000007LL
#define EPS                 1e-9
#define io                  ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAXN = 1e5+5;

int SOD(int n){
	int ans = 0;
	while(n){
		ans += (n%10);
		n /= 10;
	}
	return ans;
}

int main(){
	io;
	int n, a, b;
	cin >> n >> a >> b;
	ll ans = 0;
	for(int i = 1;i <= n; i++){
		if(SOD(i) >= a && SOD(i) <= b)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int N; cin >> N;
  int L[2005] = {};
  for (int i = 0; i < N; i++)
  {
    cin >> L[i];
  }
  
  sort(L, L + N);
  
  int ans = 0;
  for (int x = 0; x < N - 2; x++)
  {
    int a = L[x];
    for (int y = x + 1; y < N - 1; y++)
    {
      int b = L[y];
      for (int z = y + 1; z < N; z++)
      {
        int c = L[z];
        if (c <= abs(a - b))
          continue;
        else if (c >= a + b)
          break;
        else // abs(a - b) < c < a + b
          ans ++;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
results = {"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(N):
    result = input()
    results[result] += 1
print("AC x "+str(results["AC"]))
print("WA x "+str(results["WA"]))
print("TLE x "+str(results["TLE"]))
print("RE x "+str(results["RE"]))

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

int sum(i64 n) {
  if(n < 10) return n;
  return n % 10 + sum(n / 10);
}

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

  i64 n;
  cin >> n;
  int ans = sum(n);

  string s = to_string(n);
  int sz = s.size();
  ans = max(ans, (s[0] - '0') - 1 + (sz - 1) * 9);
  cout << ans << endl;
}


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

using namespace std;

int main(){

    int N, M = 0;
    int K = 0;
    int A;
    cin >> N >> M;

    vector<int> like(M, 0);

    for(int i = 0; i < N; i++ ){
        cin >> K;
        for(int j = 0; j < K; j++){
            cin >> A;
            like[A - 1]++;
        }
    }

    int totalLike = 0;
    for(int i = 0; i < M; i++){
        if(like[i] == N){
            totalLike++;
        }
    }

    if(N == 1){
        totalLike = K;
    }

    cout << totalLike;

}

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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

int N, A, B;
int h[100001];

bool ok(int k)
{
  int sum = 0;
  Rep(i, N) {
    int rest = h[i] - (k * B); 
    if( rest > 0 ) sum += (rest + A - B - 1) / (A - B);
  }

  if( sum <= k ) return true;
  else return false;
}

signed main()
{
  cin >> N >> A >> B;

  Rep(i, N) cin >> h[i];

  int l = 0, r = 1e9 + 1;
  while ( r - l > 1 ) {
    int mod = (l + r) / 2;
    if ( ok(mod) ) r = mod;
    else l = mod;
  }

  if ( ok(l) ) cout << l << endl;
  else cout << r << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num,gen;
	scanf("%d%d", &num,&gen);
	int d[10];
	fill(d, d + 10, 0);
	for (int i = 0; i < gen; i++)
	{
		int z;
		scanf("%d", &z);
		d[z] = 1;
	}
	for (;;)
	{
		int t = num;
		bool f = true;
		for (;;)
		{
			if (t == 0)break;
			if (d[t % 10] != 0)f = false;
			t /= 10;
		}
		if (f)
		{
			printf("%d\n", num);
			return 0;
		}
		num++;
	}
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


S = str(input())
if S.islower():
    print("a")
else:
    print("A")

Measured memory_bytes: 10792
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;

int n;
int a[100005];
set<int> have;
set<int> need;

int rek(int k) {
    if (have.count(k)) return 1;
    if (need.count(k)) return 0;
    need.insert(k);
    for(int* i = upper_bound(a, a+n, k); i < a + n; ++i)
        if (rek(*i - k)) return 1;
    return 0;
}

int main() {
    int k;
    scanf("%d %d", &n, &k);
    int g;
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        have.insert(a[i]);
        if (i == 0)
            g = a[i];
        else g = __gcd(g, a[i]);
    }
    sort(a, a+n);
    if (k % g == 0 && k <= a[n-1]) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    vector<int> order;
    vector<pair<int, int>> pos;
    repi(i, n, 0)
    {
        int x, y;
        cin >> x >> y;
        pos.push_back({x, y});
        order.push_back(i);
    }
    double ans = 0;
    double fact = 0;
    do
    {
        repi(i, n, 1)
        {
            ans += sqrt(pow(pos[order[i]].first - pos[order[i - 1]].first, 2) + pow(pos[order[i]].second - pos[order[i - 1]].second, 2));
        }
        fact++;
    } while (next_permutation(order.begin(), order.end()));
    cout << fixed << setprecision(10) << ans / fact << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }

    let r = if (b / k) - (a / k) >= 1 || a % k == 0 || b % k == 0 {
        "OK"
    } else {
        "NG"
    };

    println!("{}", r);
}


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    ll N;
    cin >> N;
    vector<ll> L(N);
    ll count=0;
    rep(x,N) cin >> L[x];
    sort(L.begin(), L.end());
    for(ll i=0; i<N-2; i++){
        for(ll j=i+1; j<N-1;j++){
            for(ll k=j+1; k<N; k++){
                if(L[i]!=L[j] && L[j]!=L[k]){
                    if(L[k]<L[i]+L[j]) count++;
                }
            }
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

const int N = 1e6;


int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    char c;
    cin >> c;

    if(c >= 'A' and c <= 'Z') cout << "A";
    else cout << "a";

    return 0;
}



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

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    if(x % (y + z) < z) cout << x / (y + z) - 1 << endl;
    else cout << x / (y + z) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

s = 0
for i in range(1, n-1):
  if p[i+1] > p[i] and p[i] > p[i-1]:
    s += 1
  elif p[i-1] > p[i] and p[i] > p[i+1]:
    s += 1
print(s)

Measured memory_bytes: 3060
n = int(raw_input())
Card = [[] for _ in [0]*n]
Cost = {}
for i in range(n):
  Card[i] = map(int, raw_input().split())
  Cost[(i, i)] = 0
for i in range(1, n):
  for j in range(0, n-i):
    a = j+i
    Cost[(j, a)] = min([Card[j][0] * Card[k][1] * Card[k+1][0] * Card[a][1] + Cost[(j, k)] + Cost[(k+1, a)] for k in range(j, j+i)])
print Cost[0, n-1]

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

int main(){
	int t,n,s[22],f[22],i,x;
	
	while(cin>>t){
	      if(t==0){
	          return 0;
	          }
	cin>>n;
	      
	x=0;      
	
	for(i=0;i<n;i++){
	    cin>>s[i]>>f[i];
	    x=x+f[i]-s[i];
	    }
	
	if(x-t>=0){
	   cout<<"OK"<<endl;
	   }else{
	   cout<<t-x<<endl;
	   }
	
	}
	
	return 0;
	}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, ok = 0;
vector<int> a;

bool f(int mid, bool out = 0){
   vector<int> b = a;

   int m0 = 2*mid;
   vector<int> v;
   int sum = 0;

   for (int i = 0; i < n; ++i)
   {
      int x = i-1, y = i;
      if(x < 0)x += n;
      assert(m0 % 2 == 0);
      sum += m0;
      if(out){
         v.pb(m0);
      }
      b[x] -= m0 / 2;
      b[y] -= m0 / 2;
      m0 = b[y] * 2;
   }

   if(out){
      for (int i = 0; i < n; ++i)
      {
         cout<<v[i]<<' ';
      }
   }

   return sum-ok <= 0;
}

int32_t main(){_

   cin>>n;
   a.resize(n);
   

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
      ok += a[i];
   }

   int low = 0, high = 1e9 + 1000, ans = 0;     

   while(low <= high){
      int mid = (low + high) >> 1;
      if(f(mid)){//cond => sum < 0
         ans = mid;
         low = mid + 1;
      }
      else{
         high = mid-1;
      }
   }

   f(ans, 1);

   return 0;
}

Measured memory_bytes: 3064
/*input
3 2 1
1 2 1 2
1 3 2 4
1 11
1 2
2 5

*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;
    
const int M = 3000;
int tim[52][M];
bool visited[52][M];
vector < pair <int, pii> > graph[52];
int C[52], D[52];
 
void dijkstra(int s) {
	priority_queue < pair <int, pii>, vector < pair <int, pii> >, greater < pair <int, pii> > > pq;
	pq.push({0, {1, s}});
	while (!pq.empty()) {
		int t = pq.top().F;
		int source = pq.top().S.F;
		int coins = pq.top().S.S;
		pq.pop();
		if (visited[source][coins]) {
			continue;
		}
		visited[source][coins] = 1;
		for (auto a : graph[source]) {
			int left = coins - a.S.F;
			int next = t + a.S.S;
			if (left >= 0 and tim[a.F][left] > next) {
				tim[a.F][left] = next;
				pq.push({next, {a.F, left}});
			}
		}
		if (tim[source][min(M-1,coins + C[source])] > t + D[source]) {
			pq.push({t+D[source],{source,min(M-1,coins + C[source])}});
			tim[source][min(M-1,coins + C[source])] = t + D[source];
		}
	}
}
 
void solve() {
	int n,m;
	int s;
	cin >> n >> m >> s;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < M; ++j) {
			tim[i][j] = LLONG_MAX;
		}
	}
	memset(visited, 0, sizeof(visited));
	for (int i = 0; i < m; ++i) {
		int u,v;
		int a,b;
		cin >> u >> v >> a >> b;
		graph[u].pb({v, {a,b}});
		graph[v].pb({u, {a,b}});
	}
	for (int i = 1; i <= n; ++i) {
		cin >> C[i] >> D[i];
	}
	s = min(s, M-1);
	dijkstra(s);
	for (int i = 2; i <= n; ++i) {
		int ans = LLONG_MAX;
		for (int j = 0; j < M; ++j) {
			ans = min(ans, tim[i][j]);
		}
		cout << ans << endl;
	}
}
 
int32_t main() {
    IOS;
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}




Measured memory_bytes: 7700
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;


int main(){
	int N;
	cin >> N;
	string S;
	cin >> S;

	int max = 0;
	
	for(int i = 1; i < S.length(); ++i){
		string first = S.substr(0, i);
		string second = S.substr(i, S.length() - 1);
		int first_box[27] = {};
		int second_box[27] = {};

		int count = 0;

		//cout << first << " " << second << endl;

		for(int j = 0; j < first.length(); ++j){
			first_box[first[j] - 'a']++;
		}
		for(int j = 0; j < second.length(); ++j){
			second_box[second[j] - 'a']++;
		}

		for(int j = 0; j < 27; ++j){
			if(first_box[j] > 0 && second_box[j] > 0){
				count++;
			}
		}

		max = MAX(count, max);
	}

	cout << max << endl;
}

	

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


int main() {
    int i, j, num, start, end, c;
    double a, b, rad, s, l, h;

    cin >> a >> b >> c;

    rad = M_PI /180.0 * c;

    cout << fixed <<setprecision(10) << 0.5*a*b*sin(rad) << endl;
    cout << fixed <<setprecision(10) << sqrt(b*b+a*a-2.0*a*b*cos(rad))+a+b << endl;
    cout << fixed <<setprecision(10) << b*sin(rad) << endl;

    return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <queue>
#define INF 1000000
using namespace std;
class st
{
	public:
		int vertex;
		int dis;
	st();
	st(int,int);
};

st::st()
{
	vertex=-1;
	dis=-1;
}

st::st(int v,int d)
{
	vertex=v;
	dis=d;
}

int main()
{
	int n;
	cin>>n;
	int g[101][101];
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			if (i==j)
				g[i][j]=0;
			else
				g[i][j]=INF;
		}
	for(int i=0;i<n;i++)
	{
		int f,en;
		cin>>f>>en;
		for(int j=0;j<en;j++)
		{
			int t;
			cin>>t;
			g[f][t]=1;

		}
	}

/*	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			cout<<g[i][j]<<" ";
		cout<<endl;
	}
*/
	int visited[101];
	for(int i=0;i<=n;i++)
		visited[i]=INF;

	queue<st> Q;
	st first=st(1,0);
	Q.push(first);
	while(!Q.empty())
	{
		st now=Q.front();
		Q.pop();
		for(int i=1;i<=n;i++)
		{
			if(g[now.vertex][i]+now.dis<visited[i])
			{
				visited[i]=g[now.vertex][i]+now.dis;
				Q.push(st(i,visited[i]));
			}
		}
	}
	
	for(int i=1;i<=n;i++)
		cout<<i<<" "<<(visited[i]>=INF?-1:visited[i])<<endl;
	return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
using ll = long long;

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

  int A[N];
  rep(i,0,N-1) cin >> A[i];

  map<ll, ll> m;
  ll current_idx = 0;
  bool skipped = false;
  for (ll i = 0; i < K; i++) {
    if (!skipped && m.count(current_idx) != 0) {
      ll len = i - m[current_idx];
      i = K - (K - i) % len;
      i -= len;
      skipped = true;
    }
    m[current_idx] = i;
    current_idx = A[current_idx] - 1;
  }

  cout << current_idx + 1 << endl;
  return 0;
}


Measured memory_bytes: 14276
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double pi = 3.141592653589793;
  double Arad = -pi/30*M;
  int x = H*60 + M;
  double Hrad = -(pi/360 * x);
  
  double a = pow((B*cos(Arad) - A*cos(Hrad)),2);
  double b = pow((B*sin(Arad) - A*sin(Hrad)),2);
  double c = pow(a+b,0.5);
  cout <<setprecision(22)<< c << endl;
}

Measured memory_bytes: 4420
#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];
  }
  int cnt = 0;
  while(1){
    bool flag = false;
    for(int i=0; i<N; i++){
      if(A[i] % 2 !=0){
        flag = true;
      }
    }
    if(!flag){
      cnt++;
      for(int i=0; i<N; i++){
        A[i] /= 2;
      }
    }else{
      cout << cnt << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  double N;
  cin >> N;
  
  double ans;
  if((int)N%2 == 0)  ans = 1.0/2;//1.0にしないとint同士の計算になり，0になる
  else  ans = (N+1)/2/N;
  
  //cout << ans << endl;
  printf("%lf", ans);
 
}


Measured memory_bytes: 256
# /user/bin/python
# -*- coding: utf-8 -*-
import sys 


s = str(input())
t = str(input())


def solve(s,t):
  for i in range(len(s)):
    s = s[-1] + s[:-1]
    if s == t:
      return True
  return False

if solve(s,t):
  print("Yes")
else:
  print("No")

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

int main() {
  int K, X;
  cin >> K >> X;
  int A, B;
  A = X-K+1;
  B = X+K-1;
  for (int i = A; i < B; i++){
  cout << i;
  cout <<" ";
  }
  cout << B;
}


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


bool compare(pair<long long , long long> a, pair <long long , long long > b) {
    return a.second < b.second;
}

int N;

vector<pair<long long , long long>> v;

int main() {
    cin >> N;
  
   v.resize(N);
  
    for (int i = 0; i < N; ++i) cin >> v[i].first >> v[i].second;
  
    sort(v.begin(), v.end(), compare);

    bool ok = true;
    long long sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += v[i].first;
        if (sum > v[i].second) ok = false;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <string.h>
char s[1000005];
int min(int a,int b){ return a<b?a:b; }
int max(int a,int b){ return a>b?a:b; }
int main(){
	scanf("%s",&s); int n=strlen(s),beg=0,ret=0;
	while(beg<n)
	{
		if(s[beg]!='J') { beg++; continue; }
		int j=0,o=0,i=0;
		while(beg<n && s[beg]=='J'){ j++; beg++;}
		while(beg<n && s[beg]=='O'){ o++; beg++;}
		while(beg<n && s[beg]=='I'){ i++; beg++;}
		if(o==min(j,min(o,i)))
		{
			ret=max(ret,o);
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1944
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;


int main() 
{
	ll a[10452]={};	//素数を格納する
	ll t(0);		//t番目の素数を求めたい
	while(t<10452)
	{
		if(t==0){a[t]=2;}	//最初の素数は2
		else
		{
			for(ll i =a[t-1]+1;i<110000;i++)	//前の素数+1から探索
			{
				for(ll j=0;j<t;j++)
				{
					if(i%a[j]==0){break;}	//t-1番目以前の素数で割り切れたらダメ
					if(j==(t-1)){a[t]=i;}	//t-1番目までの全てで割り切れなければ素数
				}
				if(a[t]!=0){break;}	
			}
		}
		t++;
	}
	
	ll n,p;
	while(cin >> n >> p && n!=-1 && p!=-1)
	{	
		//nより大きい最初の素数の番号を突き止める
		ll x(0);
		REP(i,n+1000){	if(a[i]>n){ x=i;	break;	}}
		
		ll b[10000]={};
		ll c(0);
		
		for(ll i=x;i<x+100;i++){
			for(ll j=i;j<x+100;j++){
				b[c]=a[i]+a[j];
				c++;
		}}
		
		sort(b,b+(50*101));
		
		cout << b[p-1] << endl;
	}
	return 0 ;
}

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

using namespace std;

int main()
{
    int n ;
    cin>>n ;
    vector< pair<int , int> >vp ;
    int arr[n] ;
    int s1 = 101 , e1 = 0 , s2 = 101 , e2 = 0;
    for(int i = 0 ; i < n ; ++i)
    {
        int x , y , z;
        cin>>x>>y>>z ;
        vp.push_back({x , y});
        s1 = min(s1 , x) ;
        e1 = max(e1 , x);
        s2 = min(s2 , y) ;
        e2 = max(e2 , y);
        arr[i] = z ;
    }
    if(n == 1)
    {
        if(arr[0] > 0)
          cout<<vp[0].first<<" "<<vp[0].second<<" "<<arr[0]<<"\n" ;
        else
        {
            int x = (100 - vp[0].first) + (100 - vp[0].second);
            if(x == 0)
            {
                cout<<99<<" "<<99<<" "<<arr[0]+2<<"\n";
            }
            else
                cout<<100<<" "<<100<<" "<<x+arr[0]<<"\n";
        }
        return 0 ;
    }
    int dist = abs(vp[0].first - vp[1].first) + abs(vp[1].second - vp[1].second);
    for(int i = 0 ; i <= 100 ; ++i)
    {
        for(int j = 0 ; j <= 100 ; ++j)
        {
            set<long long>s ;
            bool t = false ;
            for(int k = 0 ; k < n ; ++k)
            {
                if(arr[k] > 0)
                  s.insert(1ll * arr[k] + (abs(vp[k].first - i) + abs(vp[k].second - j)) * 1ll);
                else
                  t = true ;
            }
            if(t == true)
            {
                if(s.size() == 0)
                {
                    int x = 1e9 ;
                    for(int k = 0 ; k < n; ++k)
                    {
                       x = min(x , abs(i - vp[k].first) + abs(j - vp[k].second));
                    }
                    if(x > 0)
                        return cout<<i<<" "<<j<<" "<<x , 0 ;
                }
                else if(s.size() == 1)
                {
                    int x = 1e9 ;
                    for(int k = 0 ;k < n ; ++k)
                    {
                        if(arr[k] == 0)
                            x = min(x , abs(i - vp[k].first) + abs(j - vp[k].second));
                    }
                    int h = (*s.begin());
                    if(h <= x && h > 0)
                        return cout<<i<<" "<<j<<" "<<h , 0 ;
                }
                continue;
            }
            if(s.size() == 1)
            {
                int h = (*s.begin());
                if(h > 0)
                {
                    cout<<i<<" "<<j<<" "<<h<<"\n";
                    return 0 ;
                }
            }
        }
    }
    return 0 ;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[][] l = new int[2][m];
                for(int i = 0 ; i < m ; i++){
                        for(int j = 0 ; j < 2 ; j++){
                                l[j][i] = sc.nextInt();
                        }
                }
                for(int i = 0 ; i < 2 ; i++){
                        Arrays.sort(l[i]);
                }
                sc.close();
                System.out.println(Math.max(0 , l[1][0] - l[0][m - 1] + 1));
        }
}

Measured memory_bytes: 61692
l=[]
l.append(list(map(int,input().split())))
l.append(list(map(int,input().split())))
l.append(list(map(int,input().split())))
for i in range(2):
  if l[i][1]-l[i][0]!=l[i+1][1]-l[i+1][0] or l[i][2]-l[i][1]!=l[i+1][2]-l[i+1][1]:
    print('No')
    break
  if i==1:
    print('Yes')


Measured memory_bytes: 3060
N,M = map(int, input().split())

A = set([int(input()) for _ in range(M)])

lis = [0]*(N+1)
lis[0] = 1


for i in range(1,N+1):
    lis[i] = (lis[i-1] + lis[i-2])%(10**9+7)
    if i in A:
        lis[i] = 0

print(lis[N])


Measured memory_bytes: 18788
# ABC134C - Exception Handling
def main():
    N, *A = map(int, open(0))
    sorted_A = sorted(A)
    m1, m2 = sorted_A[-1], sorted_A[-2]
    ans = [m1 if i != m1 else m2 for i in A]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 28956
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scanf("%d", &x)
	fmt.Scanf("%d", &y)

	var answer bool
	for i := 0; i <= x; i++ {
		tsuru := i
		kame := x - i

		if tsuru*4+kame*2 == y {
			answer = true
		}
	}

	if answer == true {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<set<ll>> E(n);
  for(ll i=0;i<m;i++) {
    ll a,b;
    cin >> a >> b;
    a--;b--;
    E[a].insert(b);
    E[b].insert(a);
  }
  for(ll i=1;i<n-1;i++) {
    if(E[i].count(0)&&E[i].count(n-1)) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 28416