akhauriyash/Code-Regression huggingface dataset:
use std::error::Error;
use std::io;

pub fn main() {
    if let Err(_e) = run() {
        panic!("failed.");
    }
}

fn run() -> Result<(), Box<dyn Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    let input_num: Vec<i32> = input
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    input.clear();
    let a = input_num[0] as f64;
    let b = input_num[1] as f64;
    let h = input_num[2] as f64;
    let m = input_num[3] as f64;
    let h_d = 30f64 * h + 0.5f64 * m;
    let m_d = 6f64 * m;
    let x1 = b * m_d.to_radians().sin();
    let y1 = b * m_d.to_radians().cos();

    let x2 = a * h_d.to_radians().sin();
    let y2 = a * h_d.to_radians().cos();

    let result = ((x1 - x2).powf(2f64) + (y1 - y2).powf(2f64)).sqrt();
    println!("{}", result);

    Ok(())
}


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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 410, Mod = 1e9 + 7;

int f[N][N], sum[N][N];

int fpm(int x, int power) {
	int res = 1;
	for (; power; power >>= 1, x = 1ll * x * x % Mod)
		if (power & 1) res = 1ll * res * x % Mod;
	return res;
}

inline int Plus(int a, int b) {
	return (a += b) >= Mod ? a - Mod : a;
}

int a[N], b[N];

int main () {

	File();

	int n = read(), c = read();

	For (i, 1, n) a[i] = read();
	For (i, 1, n) b[i] = read();

	For (i, 1, *max_element(b + 1, b + n + 1)) For (j, 0, c)
		sum[i][j] = Plus(sum[i - 1][j], fpm(i, j));

	f[0][0] = 1;
	For (i, 1, n)
		For (j, 0, c) For (k, 0, j) {
			f[i][j] = (f[i][j] + 1ll * f[i - 1][j - k] * (sum[b[i]][k] + Mod - sum[a[i] - 1][k])) % Mod;
		}
	printf ("%d\n", f[n][c]);

	return 0;

}


Measured memory_bytes: 1536
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n == 1){
            System.out.println(1);
            return;
        }
        List<Long> li = new ArrayList<Long>(){{add((long)2);add((long)1);}};
        int ans = Integer.MAX_VALUE;
        for(int i = 2; i < n; i++){
            li.add(li.get(i-2) + li.get(i-1));
        }
        System.out.println(li.get(n-2) + li.get(n-1));
    }
}
 

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>

int main()
{
  char  str[200001], *p;
  int  i, j;

  scanf("%s", str);

  i = 0;
  while( str[i] != 'A'){
    i++;
  }
  j = strlen(str);
  while( str[j] != 'Z'){
    j--;
  }

  printf("%d\n", j - i + 1);

  return 0;
}

Measured memory_bytes: 384
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B;
    R(A,B);
    if((A-B)%2)W("IMPOSSIBLE");
    else W(abs(A+B)/2);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int Digitsum(int x) {
	int sum = 0;
	while (x > 0) {
		sum += x % 10;
		x /= 10;
	}
	return sum;
}
int main()
{
	int N, A, B, count = 0;
	scanf("%d%d%d", &N, &A, &B);
	for (int i = 1; i <= N; i++) {
		if (Digitsum(i) >= A && Digitsum(i) <= B) {
			count += i;
		}
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
x1,y1,x2,y2 = map(int,input().split())
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
x4 = x1 - dy
y3 = y2 + dx
y4 = y1 + dx

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

Measured memory_bytes: 3620
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String first = sc.next();
		String second = sc.next();
		String result = "";
		
		System.out.println(compareson(first, second));
	}
	public static String compareson(String a, String b) {
		if(a.length() > b.length()) {
			return "GREATER";
		} else if(a.length() < b.length()) {
			return "LESS";
		} else {
			return value(a, b);
		}
	}
	public static String value(String a, String b) {
		for(int i = 0; i < a.length(); i++) {
			int val1 = Character.getNumericValue(a.charAt(i));
			int val2 = Character.getNumericValue(b.charAt(i));
			if(val1 > val2) {
				return "GREATER";
			} else if(val1 < val2) {
				return "LESS";
			}
		}
		return "EQUAL";
	}
}

Measured memory_bytes: 21844
import sys
import itertools
import bisect
from operator import itemgetter
 
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
#include <stdio.h>
int main(void){
  int data,judge,point;
  int i,j,sum,max,min;
  for(i=0;1;i++){
    scanf("%d",&judge);
    if(judge==0) break;
    sum=0;
    max=0;
    min=1000;
    for(j=0;j<judge;j++){
      scanf("%d",&point);
      sum+=point;
      max = (max<point) ? point:max;
      min = (min>point) ? point:min;
    }
    data=sum-min-max;
    data/=(judge-2);
    printf("%d\n",data);
  }
  return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  int m1,m2,d1,d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if(m1==m2)cout << 0 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		long sum;
		ArrayList<Integer> list;

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			list = new ArrayList<Integer>();
			for (int i = 0; i < n; i++) {
				list.add(sc.nextInt());
			}
			Collections.sort(list);
			int k = list.size() - 1;
			sum = 0;
			for (int i = 0; i < list.size(); i++) {
				sum += list.get(i) * k;
				k--;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 13000
using System;

namespace newEx
{
    class Program
    {
        static void Main(string[] args)
        {
            //string[] l = Console.ReadLine().Split(' ');
            //int p = int.Parse(l[0]);
            //int q = int.Parse(l[1]);
            //int r = int.Parse(l[2]);

            string l = Console.ReadLine();
            int r = int.Parse(l);

            Console.WriteLine(area(r));
        }

        static int area(int r) //修正200630
        {
            return 3 * r * r;
        }
    }
}


Measured memory_bytes: 27360
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  vec p(n), q(n);
  rep(i,n){
    cin >> p[i];
  }
  rep(i,n){
    cin >> q[i];
  }

  int n_p=0, n_q=0;
  while(next_permutation(all(p))){
    n_p++;
  }
  while(next_permutation(all(q))){
    n_q++;
  }

  prt(abs(n_p-n_q));


}


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

using namespace std;

int64_t a[100'000];

int main()
{
    int n;

    cin >> n;

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

    sort(a, a + n);

    int negidx = 0;
    for (int i = 0; i < n; i++)
    {
        negidx = i;
        if (a[i] >= 0)
        {
            break;
        }
    }

    int64_t nsum = accumulate(a, a + negidx, 0LL);
    int64_t psum = accumulate(a + negidx, a + n, 0LL);
    int64_t s = psum - nsum;
    if (negidx % 2 == 1)
    {
        s -= a[negidx] - a[negidx - 1];
        int64_t med = a[negidx] + a[negidx - 1];
        s += max(med, -med);
    }

    cout << s << endl;

    return 0;
}

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

int main() {
    int l, r;
    scanf("%d%d", &l, &r);
    int ans = INT_MAX;
    if (r - l + 1 >= 2019) {
        printf("0\n");
        return 0;
    } else {
        ans = INT_MAX;
        for (int i = l; i <= r; i++) {
            for (int j = i+1; j <= r; j++) {
                ans = min(ans, (i % 2019) * (j % 2019) % 2019);
            }
        }
        printf("%d\n", ans);
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int N;
vector<pair<int, int>> P;
llong T = 0, A = 0;
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int t, a;
		cin >> t >> a;
		auto p = make_pair(t, a);
		P.push_back(p);
	}

	T = P[0].first;
	A = P[0].second;
	for (int i = 1; i < P.size(); i++) {
		llong mul = max((T - 1) / P[i].first, (A - 1) / P[i].second);
		mul++;
		T = P[i].first * mul;
		A = P[i].second * mul;
	}
	cout << T + A << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.HashMap

object Main extends App {
  val h = new HashMap[Int,Int]
  val r = new ArrayBuffer[String]
  val q = readLine.split(" ").map(_.toInt)
  var max = (-1,-1)
  for(i<-1 to q(1)) {
    val n = readLine.split(" ").map(_.toInt)
    if(h.contains(n(0)))
      h.update(n(0),h(n(0)) + n(1))
    else
      h += (n(0)->n(1))

    if(max._1 == n(0) && max._2 > h(n(0))) {
      val a =  h.toArray.sortWith{ (x,y) =>
        if(x._2>y._2) true else if(x._2==y._2 && x._1 < y._1) true else false
      }
      max = (a(0)._1,a(0)._2)
    } else if(max._2 < h(n(0))) {
      max = (n(0),h(n(0)))
    } else if(max._2==h(n(0)) && max._1 > n(0)) {
      max = (n(0),h(n(0)))
    }

    r += max._1 + " " + max._2
  }
  println(r.mkString("\n"))
}

Measured memory_bytes: 146224
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		int a; cin >> a; a++;
		A[a]++;
	}
	int res = 0;
	for(int i = 1; i <= 100000; i++) {
		MAX(res, A[i] + A[i - 1] + A[i + 1]);
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 200005, inf = 0x3f3f3f3f;

inline int read()
{
	int ret, f=1;
	char c;
	while((c=getchar())&&(c<'0'||c>'9'))if(c=='-')f=-1;
	ret=c-'0';
	while((c=getchar())&&(c>='0'&&c<='9'))ret=(ret<<3)+(ret<<1)+c-'0';
	return ret*f;
}

int n;
char s[maxn];
ll ans;

int head[maxn], tot;
struct edge{
	int nxt, to;
}e[maxn<<1];

void Addedge(int x, int y)
{
	e[++tot] = (edge){head[x], y};
	head[x] = tot;
}

int f[maxn][2], siz[maxn], bat[maxn];

void dfs1(int x, int fa)
{
	siz[x] = (s[x] == '1');
	bat[x] = (s[x] == '1'? 0: inf);
	int id;
	for(int i = head[x]; i; i = e[i].nxt)
	{
		id = e[i].to;
		if(id == fa)	continue;
		dfs1(id, x);
		if(f[id][0] + 1 > f[x][0])
		{
			f[x][1] = f[x][0];
			f[x][0] = f[id][0] + 1;
		}
		else if(f[id][0] + 1 > f[x][1])
		{
			f[x][1] = f[id][0] + 1;
		}
		siz[x] += siz[id];
		if(siz[id])
			bat[x] = min(bat[x], f[id][0] + 1);
	}
}

void dfs2(int x, int fa)
{
	ans += max(min(f[x][0], f[x][1] + 2) - bat[x], 0);
	int id, tmp;
	for(int i = head[x]; i; i = e[i].nxt)
	{
		id = e[i].to;
		if(id == fa)	continue;
		tmp = (f[x][0] == f[id][0] + 1? f[x][1]: f[x][0]) + 1;
		if(tmp + 1 > f[id][0])
		{
			f[id][1] = f[id][0];
			f[id][0] = tmp;
		}
		else if(tmp + 1 > f[id][1])
			f[id][1] = tmp;
		if(siz[id] != siz[1])	bat[id] = min(bat[id], tmp);
		dfs2(id, x);
	}
}

int main()
{
	n = read();
	int u, v;
	for(int i = 1; i < n; ++i)
	{
		u = read();
		v = read();
		Addedge(u, v);
		Addedge(v, u);
	}
	scanf("%s", s + 1);
	dfs1(1, 0);
	dfs2(1, 0);
	printf("%lld", ans + 1);
	return 0;
}

Measured memory_bytes: 14592
n,m,*a=map(int,open(0).read().split())
c=[bin(i)[::-1].index("1") for i in a]
if sum(c)!=c[0]*n:
    print(0)
    exit()
from fractions import *
b=a[0]
for i in a:
    b=(i*b)//gcd(i,b)
    if b>2*m:
        print(0)
        exit()
print((m-b//2)//b+1)  

Measured memory_bytes: 14092
import copy
import sys
input = sys.stdin.readline

n,k = map(int, input().split())
a = list(map(int, input().split()))

new_a = [0 for i in range(n)]
for i in range(k):
    for j in range(n):
        new_a[max(j-a[j], 0)] += 1
        if j+a[j]+1 < n:
            new_a[j+a[j]+1] += -1
    for j in range(n):
        if j > 0:
            new_a[j] += new_a[j-1]
    if new_a == [n for i in range(n)]:
        a = copy.copy(new_a)
        break
    a = copy.copy(new_a)
    new_a = [0 for i in range(n)]

print(" ".join(list(map(str, a))))

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

#define MAXN 100005
#define ll long long int

int gcd(int a,int b){
    if(b==0)return a;
    else return gcd(b,a%b);
}

int main(){
    int x;
    cin>>x;
    int t=gcd(x,360);
    t=360/t;
    cout<<t<<"\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,ll>>>;
using pp=pair<ll,pair<ll,ll>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000000000000

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

int main(){
  string S;
  cin>>S;
  int N=S.size();
  vector<vector<ll>> count(N+1,vector<ll>(4,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<4;j++){
      count[i+1][j]=count[i][j];
    }
    if(S[i]=='A'){
      count[i+1][1]++;
    }else if(S[i]=='B'){
      count[i+1][2]++;
    }else if(S[i]=='C'){
      count[i+1][3]++;
    }else{
      count[i+1][0]++;
    }
  }

  ll Q=count[N][0];
  ll num1=modpow(3,Q,MOD);
  ll num2=modpow(3,Q-1,MOD);
  ll num3=modpow(3,Q-2,MOD);
  ll num4=modpow(3,Q-3,MOD);

  ll ans=0;
  for(int i=0;i<N;i++){
    ll x;
    if(S[i]=='B'){
      x=count[i][1]*(count[N][3]-count[i+1][3])%MOD;
      ans+=x*num1%MOD;
      ans%=MOD;

      x=count[i][1]*(count[N][0]-count[i+1][0])%MOD;
      ans+=x*num2%MOD;
      ans%=MOD;

      x=count[i][0]*(count[N][3]-count[i+1][3])%MOD;
      ans+=x*num2%MOD;
      ans%=MOD;

      x=count[i][0]*(count[N][0]-count[i+1][0])%MOD;
      ans+=x*num3%MOD;
      ans%=MOD;
    }else if(S[i]=='?'){
      x=count[i][1]*(count[N][3]-count[i+1][3])%MOD;
      ans+=x*num2%MOD;
      ans%=MOD;

      x=count[i][0]*(count[N][3]-count[i+1][3])%MOD;
      ans+=x*num3%MOD;
      ans%=MOD;

      x=count[i][1]*(count[N][0]-count[i+1][0])%MOD;
      ans+=x*num3%MOD;
      ans%=MOD;

      x=count[i][0]*(count[N][0]-count[i+1][0])%MOD;
      ans+=x*num4%MOD;
      ans%=MOD;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 10376
H, W = map(int, input().split())
S_array = list(input() for i in range(H))


def check_around(x, y):
    cnt = 0
    if 0 < x and 0 < y and S_array[y - 1][x - 1] == '#':
        cnt += 1
    if 0 < y and S_array[y - 1][x] == '#':
        cnt += 1
    if x < W - 1 and 0 < y and S_array[y - 1][x + 1] == '#':
        cnt += 1
    if 0 < x and S_array[y][x - 1] == '#':
        cnt += 1
    if x < W - 1 and S_array[y][x + 1] == '#':
        cnt += 1
    if 0 < x and y < H - 1 and S_array[y + 1][x - 1] == '#':
        cnt += 1
    if y < H - 1 and S_array[y + 1][x] == '#':
        cnt += 1
    if x < W - 1 and y < H - 1 and S_array[y + 1][x + 1] == '#':
        cnt += 1
    return cnt


for y in range(H):
    line_str = ''
    for x in range(W):
        cur = S_array[y][x]
        if cur == '.':
            line_str += str(check_around(x, y))
        else:
            line_str += cur
    print(line_str)



Measured memory_bytes: 3064
N = int(input())

res = []
while N != 0:
    p = N % 26
    if p == 0:
        res.append('z')
        N = (N // 26) - 1
    else:
        res.append(chr(p + 96))
        N = N // 26

res.reverse()
result = ''.join(res)
print(result)


Measured memory_bytes: 9168
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        String S =sc.next();
        String A ;
        int ans=0;
        int answer=0;
        int result=1000000000;
        int num[]=new int[3];
        
        String [] List = S.split("");
        
        for(int i=0;i<List.length-2;i++){
            
            A=List[i]+List[i+1]+List[i+2];
            ans=Integer.parseInt(A);
            answer=Math.abs(753-ans);
            if(answer<result){
                result=answer;
            }
            
            
        }
        
        System.out.println(result);
        
        
        
        
        
        
    }
}


Measured memory_bytes: 39272
n=int(input())

def output(x):
	print(x,flush=True)
	nxt=input()
	if nxt=="Vacant":
		exit()
	return nxt=="Male"

Lgen=output(0)
Rgen=output(n-1)

l=0
r=n-1
while True:
	m=(l+r)//2
	gen=output(m)
	if gen==Lgen:
		if (m-l)%2:
			r=m
			Rgen=gen
		else:
			l=m
			Lgen=gen
	else:
		if (m-l)%2:
			l=m
			Lgen=gen
		else:
			r=m
			Rgen=gen

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

string s;

int main()
{
	cin>>s;
	if(s[0]=='S' && s[1]=='U') cout<<"7\n";
	else if(s[0]=='M') cout<<"6\n";
	else if(s[0]=='T' && s[1]=='U') cout<<"5\n";
	else if(s[0]=='W') cout<<"4\n";
	else if(s[0]=='T' && s[1]=='H') cout<<"3\n";
	else if(s[0]=='F') cout<<"2\n";
	else cout<<"1\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int f=0,p=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            f++;
        }
        if(s[i]=='B')p++;
    }
    if(f==3||p==3)cout<<"No";
    else cout<<"Yes";
 
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
def cmb(n, r, mod):
    x = 1 
    y = 1
    for i in range(r):
        x = x*(n-i)%(mod)
    for i in range(1,r+1):
        y = y*i%(mod)
    return x * pow(y,mod-2,mod) %mod

v = int(pow(2,n,10**9+7)-1-cmb(n,a,10**9+7)-cmb(n,b,10**9+7))
if v >= 0:
    print(v)
else:
    if v+10**9+7 >= 0:
        print(v+10**9+7)
    else:
        print(v+2*(10**9+7))

Measured memory_bytes: 3064
import Data.List
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad.ST
import Control.Monad

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

solve :: Int -> Int -> Int -> [(Int,Int)] -> [(Int,Int)] -> [Int]
solve n _ _ lrs pqs = map f pqs
  where
    f (p,q) = tbl V.! q VU.! q - tbl V.! (p-1) VU.! q
    tbl = V.scanl1' (VU.zipWith (+))
          $ V.map (VU.scanl1' (+))
          $ V.generate (n+1)
          $ \i -> VU.slice (i*(n+1)) (n+1) $ VU.create $ act n lrs

act :: Int -> [(Int,Int)] -> ST s (VUM.MVector s Int)
act n lrs = do
  vec <- VUM.replicate ((n+1) * (n+1)) 0
  forM_ lrs $ \(s,r) -> VUM.modify vec (+ 1) (s*(n+1) + r)
  return vec

tmain :: B.ByteString -> [Int]
tmain cont =
  let line1 : rest = B.lines cont
      [n,m,q] = bsReadInts line1
      (part1, part2) = splitAt m rest
      form = map ((\[s,e] -> (s,e)) . bsReadInts)
  in solve n m q (form part1) (form part2)

main :: IO ()
main = putStr . unlines . map show . tmain =<< B.getContents


Measured memory_bytes: 25596
#include <stdio.h>
int main(void)
{
    int n,i,j,k,l,b,f,r,v;
    int data[4][3][10]={0};
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        data[b-1][f-1][r-1]+=v;
    }
   
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",data[i][j][k]);
            }
        printf("\n");
        }
        if(i!=3)printf("####################\n");
    }
    return 0;
    
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int wa(int n){
  int a = log10(n);
  int tmp = 0;
  for(int i = 1; i <= a; i++){
    tmp += n % 10;
    n /= 10;
  }
  tmp +=n;
  return tmp;
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  
  int tmp = 0;
  for(int i = 1; i <= N; i++){
    int w = wa(i);
    if(w >= A && w <= B) tmp += i;
  }
  cout << tmp;
}


Measured memory_bytes: 768
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
// http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/
   // 素集合データ構造
   struct UnionFind
   {
     // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
     vector<int> par;
     // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
     vector<int> sizes;
   
     UnionFind(int n) : par(n), sizes(n, 1) {
       // 最初は全てのデータiがグループiに存在するものとして初期化
       rep(i,n) par[i] = i;
     }
   
     // データxが属する木の根を得る
     int find(int x) {
       if (x == par[x]) return x;
       return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
     }
   
     // 2つのデータx, yが属する木をマージする
     void unite(int x, int y) {
       // データの根ノードを得る
       x = find(x);
       y = find(y);
   
       // 既に同じ木に属しているならマージしない
       if (x == y) return;
   
       // xの木がyの木より大きくなるようにする
       if (sizes[x] < sizes[y]) swap(x, y);
   
       // xがyの親になるように連結する
       par[y] = x;
       sizes[x] += sizes[y];
       // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
     }
   
     // 2つのデータx, yが属する木が同じならtrueを返す
     bool same(int x, int y) {
       return find(x) == find(y);
     }
   
     // データxが含まれる木の大きさを返す
     int size(int x) {
       return sizes[find(x)];
     }
   };
int main() {
    ll n,q;
    std::cin >> n>>q;
    
    UnionFind uf(n);
    
    for (int i = 0; i < q; i++) {
        ll c,x,y;
        std::cin >> c>>x>>y;
        if(c==0){
            uf.unite(x,y);
        }else{
            if(uf.same(x,y)){
                std::cout << 1 << std::endl;
            }else{
                std::cout << 0 << std::endl;
            }
        }
    }
}



Measured memory_bytes: 3180
#include<stdio.h>
int main(void)
{
	long long temp;
	long long m,n, a, b, i, gcd, lcd;
	while (scanf("%lld %lld", &a, &b) != EOF)
	{
		m = a;
		n = b;
		while (n != 0)
		{
			temp = m%n;
			m = n;
			n = temp;
		}
		gcd = m;
		lcd = a*b / gcd;
		printf("%lld %lld\n", gcd, lcd);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

  vector<ll> x(N, 0), v(N, 0);

  for (int i = 0; i < N; i++) {
    cin >> x[i] >> v[i];
  }

  // 累積和
  vector<ll> rwv(N + 1, 0);
  for (int i = 0; i < N; i++) {
    rwv[i + 1] = rwv[i] + v[i];
  }

  vector<ll> r(N + 1, 0);
  r[1] = rwv[1] - x[0];
  for (int i = 1; i < N; i++) {
    r[i + 1] = max(r[i], rwv[i + 1] - x[i]);
  }

  vector<ll> l(N + 1, 0);
  l[1] = rwv[N] - rwv[N - 1] - (C - x[N - 1]);
  for (int i = 1; i < N; i++) {
    l[i + 1] = max(l[i], rwv[N] - rwv[N - (i + 1)] - (C - x[N - (i + 1)]));
  }

  // for (int i = 0; i <= N; i++) {
  //   cout << l[i] << " ";
  // }
  // cout << endl;
  // for (int i = 0; i <= N; i++) {
  //   cout << r[i] << " ";
  // }
  // cout << endl;


  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, rwv[i] - x[i - 1]);
    ans = max(ans, rwv[N] - rwv[N - i] - (C - x[N - i]));
    if (i < N) {
      ans = max(ans, rwv[i] - 2 * x[i - 1] + l[N - i]);
      ans = max(ans, rwv[N] - rwv[N - i] - 2 * (C - x[N - i]) + r[N - i]);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4224
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for _ in range(M)]
B.sort(key = lambda x:x[1])
B = list(reversed(B))
A.sort()

num = 0
for i in range(M):
    for j in range(B[i][0]):
        if num > N-1:
            break
        if A[num] < B[i][1]:
            A[num] = B[i][1]
            num += 1
        else:
            break

print(sum(A))

Measured memory_bytes: 33080
#include<bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
using namespace std;
int main()
{
    int a, b; cin>>a>>b;
    if(b*2 >= a) cout<<0<<endl;
    else cout<<(a-2*b)<<endl;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

int a[N];
int b[N];

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

    int n;  cin >> n;

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

    ll  ans = 0;

    while (1)   {
        bool ok = 1;

        for(int i = 0 ; i < n ; ++i)    {
            if (b[i] < a[i])    {
                cout << "-1";
                return  0;
            }
            if (b[i] > a[i])    {
                int j = (i - 1 + n) % n;
                int k = (i + 1) % n;

                if (b[i] <= b[j] || b[i] <= b[k])   {
                    ok = 0;
                    continue;
                }
                if (b[i] - a[i] < b[j] + b[k])  {
                    cout << "-1";
                    return  0;
                }
                int cnt = (b[i] - a[i]) / (b[j] + b[k]);
                ans  += cnt;
                b[i] -= cnt * (b[j] + b[k]);

                if (b[i] != a[i])
                    ok = 0;
            }
        }
        if (ok) {
            cout << ans;
            return  0;
        }
    }
}


Measured memory_bytes: 1792
import java.util.*;
class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  double r = sc.nextDouble();
  System.out.println( String.format("%.6f", (r*r*Math.PI)) + " " + String.format("%.6f",(2*r*Math.PI)));
 }
} 


Measured memory_bytes: 28232
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
using namespace std;
#define pb push_back
#define F(i,a,b) for(int i=a;i<b;++i)
#define Fl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int MOD = 1000000007;
#define pie 3.141592653589793238462643383279


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

 	int t{},T{};
 	//cin>>t;T=t;
    t=1;
 	while(t--){
        //cout<<"------------- #"<<T-t<<endl;
        ll n{},m{},ans{},k{},a{},b{},c{},f{1};
        cin>>n;
        vecl v(n);
        Fl(i,0,n)cin>>v[i];
        Fl(i,1,n){
            if(v[i]<v[i-1]){
                ans+=v[i-1]-v[i];
                v[i]=v[i-1];
            }
        }
        cout<<ans<<endl;
    }
    
    
	return 0;
}

Measured memory_bytes: 4788
N, Y = map(int, input().split())
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        total = 10000*a + 5000*b + 1000*c
        if total == Y:
            print(a, b, c)
            exit()
print('-1 -1 -1')

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(new string('#', hw[1] + 2));

            for (var h = 0; h < hw[0]; h++)
            {
                Console.Write("#");
                Console.Write(Console.ReadLine());
                Console.WriteLine("#");
            }

            Console.WriteLine(new string('#', hw[1] + 2));
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
//vector<int>v;
//map<int,int>mp;
char a[5];
int main()
{
    ft
    int t,i,j,n,m,l,r,f=0,b[5];
    cin>>n>>m;
    memset(b,-1,sizeof(b));
    for(i=0; i<m; i++)
    {
        cin>>l>>r;
        if(b[l]==-1)
        {
            a[l-1]=(char)(r+48);
            b[l]=r;
        }
        else
        {
            if(b[l]!=r)
            {
                f=1;
            }
        }
    }
    if(n>1 && b[1]==0)
    {
        f=1;
    }
    if(f==1)
    {
        cout<<"-1\n";
    }
    else
    {
        for(i=0; i<n; i++)
        {
            if(b[i+1]==-1)
            {
                if(i>0)
                {
                    a[i]='0';
                }
                else
                {
                    a[i]='1';
                }
            }
        }
        if(n==1 && b[1]==-1)
        {
            a[0]='0';
        }
        a[n]='\n';
        cout<<a<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){ 
	while(true){
		int a, b;
		char op;
		cin >> a >> op >> b;
		if(op=='?'){
			break;
		}
		if(op=='+'){
			cout << a + b << endl;
		}
		if(op=='-'){
			cout << a - b << endl;
		}
		if(op=='*'){
			cout << a*b << endl;
		}
		if(op=='/'){
			cout << a/b << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

#define N 100
vector<int> G[N],rG[N],g;
bool u[N];
int n,cmp[N];
  
void add_edge(int x,int y){G[x].push_back(y);rG[y].push_back(x);}
void dfs(int x){u[x]=1;rep(i,G[x].size())if(!u[G[x][i]])dfs(G[x][i]);g.push_back(x);} 
void rdfs(int x,int k){u[x]=1;cmp[x]=k;rep(i,rG[x].size())if(!u[rG[x][i]])rdfs(rG[x][i],k);}
int scc() {
  mem(u);g.clear();rep(i,n)if(!u[i])dfs(i);mem(u);
  int k=0;rrep(i,g.size())if(!u[g[i]])rdfs(g[i],k++);return k;
}

void Main() {
  n=26;
  int m;
  while(R m && m) {
    rep(i,n) G[i].clear(),rG[i].clear();
    set<int> se;
    string s[m];
    rep(i,m) R s[i];
    rep(i,m-1) {
      bool f=1;
      rep(j,min(s[i].size(),s[i+1].size())) {
        if(s[i][j]!=s[i+1][j]) {
          add_edge(s[i][j]-'a',s[i+1][j]-'a');
          f=0;
          break;
        }
      }
      if(f&&s[i].size()>s[i+1].size()) {
        pr("no");
        goto next;
      }
    }
    scc();
    rep(i,26) se.in(cmp[i]);
    if(se.size()==n) pr("yes");
    else pr("no");
  next:;
  }

}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3116
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

cnt_d = Counter(D)
cnt_t = Counter(T)

for k, v in cnt_t.items():
    cnt_d[k] -= v
    if cnt_d[k] < 0:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 57052
let i=readLine()!.characters.split(" ").map{Int(String($0))!},x=i[0],y=i[1]
var ans=Int(2e9)
func f(a:Int, _ b:Int, _ c:Int) {
  if a <= b {
    ans=min(ans,b-a+c)
  }
}
f(x,y,0)
f(x,-y,1)
f(-x,y,1)
f(-x,-y,2)
print(ans)

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

ll kai[(1<<19)];
ll mod = 1e9 + 7;
ll iv[(1<<19)];

ll mp(ll a, ll b) {
    if (b == 0) return 1LL;
    if (b == 1) return a;
    ll ret = mp(a,b/2);
    ret *= ret;
    ret %= mod;
    if (b&1) ret *= a;
    return ret % mod;
}

ll inv(ll k) {
    return mp(k,mod-2);
}

void init() {
    kai[0] = 1;
    kai[1] = 1;
    iv[0] = inv(0);
    iv[1] = inv(1);
    for (ll i = 2; i < (1 << 19); i++) {
        kai[i] = kai[i - 1] * i % mod;
        iv[i] = inv(kai[i]);
    }
}


ll c(ll n, ll k) {
    if (k == 0) return 1;
    if (n == k) return 1;
    return kai[n] * iv[k] % mod * iv[n-k] % mod;
}

int main() {
    init();
    ll n,k;
    cin >> n >> k;
    ll ans = c(2*n-1,n-1);
    if (k >= n) {
        cout << ans << endl;
        return 0;
    }
    for (ll i = k + 1; i <= n - 1; i++) {
        ans -= c(n,i) % mod * c(n-1,i) % mod;
        ans += mod * mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8448
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef unsigned long long ll;

ll gcd(ll a, ll b){
    while(b != 0){
        ll m = a % b;
        a = b;
        b = m;
    }
    return a;
}

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

    vector<ll> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }

    ll ans = 1;
    for(int i = 0; i < n; i++){
        ans = t[i] / gcd(t[i], ans) * ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> up,bottom;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    up = fetch_vec<int>(N);
    bottom = fetch_vec<int>(N);
}

int solve(){
    vector<int> sum_u(N+1),sum_b(N+1);
    int ans=0;
    sum_u[0] = 0;
    sum_b[0] = 0;
    for (int i = 0; i < N; i++)
    {
        sum_u[i+1] = sum_u[i]+up[i];
        sum_b[i+1] = sum_b[i]+bottom[i];
    }
    for (int i = 1; i <= N; i++)
    {
        ans = max(ans, sum_u[i]+sum_b[N]-sum_b[i-1]);
    }
    cout << ans << endl;  
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


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

typedef long long int LLI;

void solve()
{
	LLI n;
	cin>>n;
	vector<LLI>A(n+1),B(n+1);
	for(LLI i=1;i<=n;++i) cin>>A[i]>>B[i];
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	LLI median_max,median_min,idx;
	if(n & 1){
		idx=(n+1)/2;
		median_min=A[idx];
		median_max=B[idx];
	}
	else{
		idx=n/2;
		median_min=A[idx]+A[idx+1];
		median_max=B[idx]+B[idx+1];
	}
	cout<<median_max-median_min+1;
	return;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

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

int main(int argc, char** argv){
	int r,c,rc;
	int r_sum,*c_sum,sum,val;
	int i,j;

	// Input
	scanf("%d %d",&r,&c);

	// Setup Table
	c_sum = malloc(sizeof(int)*c);
	for(i=0;i<c;i++){
		c_sum[i] = 0;
	}
	sum = 0;

	// Input & Output
	for(i=0;i<r;i++){
		r_sum = 0;
		for(j=0;j<c;j++){
			scanf("%d",&val);
			printf("%d ",val);
			r_sum += val;
			c_sum[j] += val;
		}
		printf("%d\n",r_sum);
		sum += r_sum;
	}
	for(j=0;j<c;j++){
		printf("%d ", c_sum[j]);
	}
	printf("%d\n",sum);

	// Release Resource
	free(c_sum);

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x, n; cin>>x>>n; 
    std::vector<int>a(n);
    for(int i=0; i<n; i++)cin>>a[i];
    sort(a.begin(), a.end()); bool ok=true; 
    int t=0; int ans;
    while(ok){
        if(count(a.begin(), a.end(), x-t)==0){ok=false; ans=x-t; break;}
        else if(count(a.begin(), a.end(), x+t)==0){ok=false; ans=x+t; break;}
        t++;
    }
    cout<<ans<<endl;   
}

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

int main() 
{
    char a;
    cin >> a;

    string small = "abcdefghijklmnopqrstuvwxyz";

    for (char ch : small)
    {
        if (a == ch)
        {
            cout << 'a' << endl;
            return 0;
        }
    }

    cout << 'A' << endl;
}

Measured memory_bytes: 3596
/*
 *created by Kraken on 04-04-2020 at 17:23
 */

import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int x = sc.nextInt(), y = sc.nextInt(), z = sc.nextInt();
		System.out.printf("%d %d %d\n", z, x, y);
	}

	static class FastReader {

		BufferedReader br;

		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=200005;

map<int, int> vis;
int n, m;
int data[maxn][2];

int main() {
    while(cin>>n>>m){
        bool ans=0;
        int u, v;
        vis.clear();
        for(int i=0;i<m;i++){
            cin>>u>>v;
            if(u==1)vis[v]=1;
            data[i][0]=u;
            data[i][1]=v;
        }
        for(int i=0;i<m;i++){
            u=data[i][0];
            v=data[i][1];
            if(v==n&&vis[u])ans=1;
        }
        cout<<(ans?"POSSIBLE":"IMPOSSIBLE")<<endl;
    }
    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <string.h>

int main() {
	char ans[10] = "No";
	int N, i, j;

	scanf("%d", &N);

	for (i = 0; i * 4 <= N; i++) {
		for (j = 0; j * 7 + i * 4 <= N; j++) {
			if (j * 7 + i * 4 == N) {
				strcpy(ans, "Yes");
			}
		}
		if (strcmp(ans, "Yes") == 0) {
			break;
		}
	}

	printf("%s", ans);

	return 0;
}

Measured memory_bytes: 128