akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        s: chars,
    }
    for &c in &s {
        puts!("{}", c);
    }
    if s.last() == Some(&'s') {
        puts!("es\n");
    } else {
        puts!("s\n");
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2236
def myAnswer(N:int,A:list,B:list) -> int:
   total = 0
   for i in range(N):
      if(A[i] < B [i]):
         total += A[i]
         if(A[i + 1] > B[i] - A[i]):
            A[i+1] -= B[i] - A[i]
            total += B[i] - A[i]
         else:
            total += A[i + 1]
            A[i + 1] = 0
         A[i] = 0
      else:
         A[i] -= B[i]
         total += B[i]
   return total

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   B = list(map(int,input().split()))
   print(myAnswer(N,A[:],B[:]))

if __name__ == '__main__':
   main()

Measured memory_bytes: 19004
n=int(input())
a=list(map(int,input().split()))
a.sort()
if a[n-1]-a[0]>=2:
  print('No')
  exit()
if a[n-1]==a[0]:
  if a[0]==n-1 or 2*a[0]<=n:
    print('Yes')
  else:
    print('No')
else:
  x=a[0]
  cnt=0
  for i in range(n):
    if a[i]==x:
      cnt+=1
    else:
      break
  if cnt<a[n-1] and 2*(a[n-1]-cnt)<=n-cnt:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 14092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int _x, _y, x, y;
			_x = parseInt(line.substring(0, line.indexOf(' ')));
			_y = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((_x | _y) == 0) break;

			if (_x >= _y) {
				x = _x;
				y = _y;
			} else {
				x = _y;
				y = _x;
			}

			int mod, step = 0;
			while (y != 0) {
				mod = x % y;
				x = y;
				y = mod;
				step++;
			}
			System.out.println(x + " " + step);
		}
	}
}

Measured memory_bytes: 21300
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    scanf("%d",&m);
    return m ;
}
inline ll lD()
{
    ll m ;
    scanf("%lld",&m);
    return m ;
}
inline double dD()
{
    double m ;
    scanf("%llf",&m);
    return m ;
}
ll LCM(ll a, ll b)
{
    return a / __gcd(a, b) * b;
}
ll power(ll a, ll b, ll m)
{
    if(!b)  return 1;
    ll t = power(a, b>>1, m)%m;
    return ((t*t)%m * (b&1 ? a : 1)%m)%m;
}
bool isPaind(int n){
string s="";
int t=n;
while(n){
    s+=n%10+'0';
 n/=10;
}
 stringstream geek(s);
   int x = 0;
   geek >> x;
   return (x==t);
}
int main()
{
    int x=D(),y=D(),cnt=0;
     for(int i=x;i<=y;++i){
        if(isPaind(i))
            cnt++;
     }
     cout<<cnt<<endl;
}


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

using namespace std;

int main()
{
    char S[10];

    while(cin >> S)
    {
        if(strcmp(S, "Sunny") == 0)
        {
            cout << "Cloudy" << endl;
        }

        else if(strcmp(S, "Cloudy") == 0)
        {
            cout << "Rainy" << endl;
        }

        else
        {
            cout << "Sunny" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100010];
int main()
{
	int n,x;
	scanf("%d%d",&n,&x);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=n;
	for (int i=1;i<=n;i++) x-=a[i];
	ans+=x/a[1];
	printf("%d\n",ans);
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i<n; i++)
#define ll long long
#define MOD 1000000007
using namespace std;;
 
int main() {
  ll N; cin >> N;
  ll a[N],sum[N]; 
  
  rep(i,0,N) {
    cin >> a[i];
    if (i ==0) sum[i] =a[i];
    else sum[i] = sum[i-1] + a[i];
  }
  
  ll ans = abs(2 * sum[0] - sum[N-1]);
  rep(i,1,N-1) {
    ll sa = abs(sum[N-1] - 2 * sum[i]);
    ans = min(sa,ans);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 6692
N=int(input())
List=input()
AList=list(List)
RCNT=AList.count("R")
BList=sorted(List)
ANUM=0
BNUM=0
ans=0
i=0
while i<N:
    if AList[i]!=BList[i]:
        ans+=1
    i+=1
print(ans//2)

Measured memory_bytes: 13064
module Main where

import Data.List
import Control.Monad
import Control.Monad.ST (runST)
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Vector.Mutable as MV
import qualified Data.Vector as V
import Data.Function (fix)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [(Int, Int)] -> [(Int, Int)] -> [Int]
solve n abList pxList = runST $ do
        graph <- MV.replicate (n + 1) []
        forM_ abList $ \(a, b) -> do 
            MV.modify graph (a:) b
            MV.modify graph (b:) a
        points <- MV.replicate (n + 1) 0
        forM_ pxList $ \(p, x) -> MV.modify points (+x) p
        let dfs = fix $ \next point parent -> do
                myPoint <- MV.read points point
                sons <- MV.read graph point
                forM_ sons $ \son ->
                    if son == parent then return ()
                    else do 
                        MV.modify points (+myPoint) son
                        next son point
        dfs 1 (negate 1)
        frozenAns <- V.freeze points
        pure . tail $  V.toList frozenAns


main = do
    (n, q) <- readTuple2
    abList <- replicateM (n - 1) readTuple2
    pxList <- replicateM q readTuple2
    putStrLn $ unwords  $ show <$> solve n abList pxList


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> h(N+1);
  for(int i=1;i<=N;i++){
    cin >> h.at(i);
  }
  vector<priority_queue<int> > v(N+1);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    v.at(A).push(h.at(B));
    v.at(B).push(h.at(A));
  }
  int64_t ans=0;
  for(int i=1;i<=N;i++){
    if(v.at(i).empty()){
      ans++;
    }else{
      if(h.at(i)>v.at(i).top()){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9596
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
n,k = map(int, stdin.readline().rstrip().split())
A = list(map(int, stdin.readline().rstrip().split()))
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]

# find loop
visited = [0]*n
visited[0] = 1
next = A[0] - 1
loop = 0
v = 0
for i in range(n):
    if visited[next] != 0:
        loop = i-visited[next]+2
        v = i
        break
    else:
        visited[next]= i+2
        next = A[next] - 1

road =  v+1 - loop
# 計算
if k <= road:
    print(visited.index(k+1) + 1)
    exit()
k = k - road
k = k%loop
print(visited.index(k+1+road) +1)


Measured memory_bytes: 32372
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "{";
    for (int i = 0; i < v.size(); ++i) {
        if(i) os << ", ";
        os << v[i];
    }
    return os << "}";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "{" << p.first << ", " << p.second << "}";
}


int main() {
    int n, r, l;
    cin >> n >> r >> l;
    vector<int> v(n);
    set<pair<int, int>> s;
    for (int i = 0; i < n; ++i) {
        s.emplace(0, i);
    }
    int prv = 0;
    vector<int> ans(n);
    for (int i = 0; i < r; ++i) {
        int d, t, x;
        scanf("%d %d %d", &d, &t, &x); d--;
        auto M = s.begin();
        ans[M->second] += (t-prv);
        s.erase(s.find({v[d], d}));
        v[d] -= x;
        s.emplace(v[d], d);
        prv = t;
    }
    auto M = s.begin();
    ans[M->second] += (l-prv);
    cout << max_element(ans.begin(),ans.end()) - ans.begin() + 1 << "\n";
    return 0;
}


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

template <typename T, typename F>
struct SegmentTree{
private:
  // using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
public:
  SegmentTree(){};
  SegmentTree(F f,T ti) : f(f),ti(ti) {}
  void build(int n_){
    n = n_;
    dat.assign(2*n,ti);
  }
  void build(const vector<T> &v){
    int n_ = v.size();
    build(n_);
    for(int i = 0; i < n; ++i) dat[n+i]=v[i];
    for(int i = n-1; i >= 0; --i)
      dat[i]=f(dat[2*i+0],dat[2*i+1]);
  }
  void set_val(int k,T x){
    dat[k+=n] = x;
    while(k > 0){
      k = k/2;
      dat[k]=f(dat[2*k+0],dat[2*k+1]);
    }
  }
  T query(int a,int b){
    T vl = ti, vr = ti;
    for(int l = a+n, r = b+n; l < r; l >>= 1, r >>= 1){
      if(l&1) vl = f(vl,dat[l++]);
      if(r&1) vr = f(dat[--r],vr);
    }
    return f(vl,vr);
  }
};

int main(){
  int N, K;
  cin >> N >> K;
  auto f = [](int a, int b){ return max(a,b); };
  SegmentTree st(f,0);
  const int M = 300001;
  st.build(vector<int>(M));
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    int t = st.query(max(0,a-K),min(M+1,a+K+1)) + 1;
    st.set_val(a,t);
  }
  cout << st.query(0,M) << '\n';
}


Measured memory_bytes: 6652
import math
import numpy as np

a, b, h, m = map(int, input().split())

TOTAL = 60. * 12

# degree
aa = math.radians(((h * 60. + m) / TOTAL ) * 360.)
bb = math.radians(m / 60. * 360.)
ax = a * math.sin(aa)
ay = a * math.cos(aa)
bx = b * math.sin(bb)
by = b * math.cos(bb)

ans = math.sqrt((ax - bx)**2 + (ay - by)**2)
print(ans)

Measured memory_bytes: 27200
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<cstring>
#include<stack>
#include<cstdlib>
#include<cmath>
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
}

Measured memory_bytes: 3588
H, W, D = map(int, input().split())
A = [tuple(map(int, input().split())) for i in range(H)]
Q = int(input())
LR = [tuple(map(int, input().split())) for i in range(Q)]

p = [None] * (H * W + 1)
for i in range(H):
    for j in range(W):
        p[A[i][j]] = (i, j)

d = []
for i in range(H*W+1):
    if i <= D:
        d.append(0)
    else:
        d.append(d[i-D] + abs(p[i][0] - p[i-D][0]) + abs(p[i][1] - p[i-D][1]))

for i in range(Q):
    print(d[LR[i][1]] - d[LR[i][0]])

Measured memory_bytes: 73180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

int main(){
  ll h,w;
  cin>>h>>w;
  ll ans;
  
  if (h==1 || w==1){
    ans=1;
    
  }else{


 	 ans=(h*w+1)/2;

  }


  cout<<ans<<endl;

}


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


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

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

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

	int a, b;
	cin >> a >> b;
	
	cout << max(a + b, max(a + a - 1, b + b - 1));
    
    cout << '\n';
    return 0;
}

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

using namespace std;

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    ll ai, ao, at, aj, al, as, az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;
    ll res = ao;
    res += 2 * (ai / 2);
    ll way1 = 2 * (aj / 2 + al / 2);
    ll way2 = 0;
    if (aj > 0 && al > 0 && ai % 2) {
        way2 += 3;
        aj--;
        al--;
        way2 += 2 * (aj / 2 + al / 2);
    }
    ll way3 = 0;
    if (aj > 0 && al > 0 && ai) {
        way3 -= 2 * (ai / 2);
        ai--;
        way3 += 2 * (ai / 2);
        way3 += 3;
        aj--;
        al--;
        way3 += 2 * (aj / 2 + al / 2);    
    }
    res += max(way1, max(way2, way3));
    cout << res << endl;
}       

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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(x => Int32.Parse(x)).ToArray();
        var a = l[0]; var b = l[1];
        if (a * b % 2 == 0) Console.WriteLine("No");
        else Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define MAX 200010
using namespace std;

char str[3][MAX];

int streq()
{
	int i = 0;
	while (str[0][i] || str[2][i])
	{
		if (str[0][i] != str[2][i]) return 0;
		i++;
	}
	return 1;
}

int main(void)
{
	int N, M;
	cin >> str[0] >> str[1] >> N >> M >> str[2];
	if (streq()) cout << N - 1 << " " << M << endl;
	else cout << N << " " << M - 1 << endl;
	return 0;
}


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

int main() {
  int N, A, AN=536870912;
  int i;
  cin >> N;
  for (i=0; i<N; i++) {
    cin >> A;
    while ( (A % AN) != 0 ) AN /= 2;
//    while ( (A % AN) != 0 ) { cout << AN << endl; AN /= 2;}////////////////
//    cout << A << ' ' << AN << endl;/////////////////
  }
  for (i=0; AN != 1; i++) AN/=2;
  cout <<i <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a >> b;
   cout << a*b;
   return 0;
} 

Measured memory_bytes: 3648
S, T = gets.chomp.split
A, B = gets.split.map(&:to_i)
U = gets.chomp

ans = [A, B]
if U == S && A > 0
  ans[0] -= 1
elsif U == T && B > 0
  ans[1] -= 1
end

puts "#{ans[0]} #{ans[1]}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int n; cin >> n;
    int d[110];
    rep(i,n) cin >> d[i];

    set<int> values;
    rep(i,n) values.insert(d[i]);
    
    print(values.size());

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
    double r = 0.0;
    int tmp;
    cin >> tmp;
    r = (double)tmp;

    double ans = 0.0;
    ans =  r * 2.0 * M_PI;
    printf("%.20f",ans);

    return 0;
}

Measured memory_bytes: 3752
M=9;main(n,i,j,k,a,b,c){
	float p=atan(1)*4/9,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%f,%f",X+i,Y+i);
		for(a=i=0;i<n;a=a>b?a:b,i++)for(b=k=0;k<9;b=b>c?b:c,k++)for(x=X[i]+cos(p*k),y=Y[i]+sin(p*k),c=j=0;j<n;j++)if(hypot(X[j]-x,Y[j]-y)<1+1e-3)c++;
	}
exit(0);}

Measured memory_bytes: 652
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define int long long
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  double L; cin>>L;
  long double A=L/3;
  long double B=A*A*A;
  cout<<fixed << setprecision(15)<<B<<endl;
}

Measured memory_bytes: 3748
// atcoder/arc091/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, a, b;
  while (cin >> n >> a >> b) {
    vec<int> v[b];
    int x = n;
    int y = b - 1;
    for (int i = 0; i < b && x; ++i) {
      for (int j = 0; j < a && x; ++j) {
        v[i].push_back(x--);
        if (x == y) break;
      }
      --y;
    }

    // for (int i = 0; i < b; ++i) cout << v[i] << endl;

    if (v[b - 1].empty()) {
      cout << -1 << endl;
      continue;
    }
    if (v[0].size() != a) {
      cout << -1 << endl;
      continue;
    }

    vec<int> u;
    for (int i = 0; i < b; ++i) {
      while (v[i].size()) {
        u.push_back(v[i].back());
        v[i].pop_back();
      }
    }

    if (u.size() != n) {
      cout << -1 << endl;
      continue;
    }

    for (int i = 0; i < u.size(); ++i) {
      if (i) cout << ' ';
      cout << u[i];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

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

template<class T>
ostream& operator<<(ostream& stream, const vector<T> v){
    stream << "[";
    for (int i=0; i<(int)v.size(); i++) cout << v[i] << " ";
    stream << "]";
    return stream;
}

int H,W,cnt[30],t[5],cr[30];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> H >> W;

    int i,j; char c;
    for (i=1; i<=H; i++)
        for (j=1; j<=W; j++){
            cin >> c;
            cnt[c-'a']++;

            if (i==H-i+1 && j==W-j+1) t[1]++;
            else if (i==H-i+1 || j==W-j+1) t[2]++;
            else t[4]++;
        }

    assert(t[2]%2==0);
    assert(t[4]%4==0);
    t[2]/=2;
    t[4]/=4;

    bool ok=0;
    int k;
    for (k=0; k<26; k++){
        if (cnt[k]<t[1]) continue;

        for (i=0; i<26; i++)
            cr[i]=cnt[i];

        cr[k]-=t[1];

        int v2=t[2],v4=t[4];

        for (i=0; i<26; i++){
            int ct=min(cr[i]/4,v4);
            cr[i]-=4*ct;

            v4-=ct;
        }

        bool p=1;
        for (i=0; i<26; i++){
            int ct=min(cr[i]/2,v2);
            cr[i]-=2*ct;

            v2-=ct;
            if (cr[i]>0) p=0;
        }

        ok|=p;
    }

    cout << (ok ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]

    kari = [[0 for i in range(101)]for j in range(101)]

    for i in range(num):
        x, y, h = data[i]
        if h > 0:
            ind = i
            break

    x, y, h = data[ind]
    for i in range(101):
        for j in range(101):
            kyori = abs(i - x) + abs(j - y)
            kari[i][j] = h + kyori


    for k in range(num):
        x, y, h = data[k]

        for i in range(101):
            for j in range(101):
                kyori = abs(i - x) + abs(j - y)
                if h == 0:
                    if kari[i][j] <= kyori:
                        pass
                    else:
                        kari[i][j] = -1
                elif h + kyori == kari[i][j]:
                    pass
                else:
                    kari[i][j] = -1

    for i in range(101):
        for j in range(101):
            if kari[i][j] >= 0:
                print(i, j, kari[i][j])




if __name__ == '__main__':
    main()



Measured memory_bytes: 44396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int tmp = N%1000;
        if(tmp==0) {
            System.out.println(0);
        } else {
            System.out.println(1000-tmp);
        }
    }
}


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

int n, x;
deque<int> ans;

int main() {
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1)
		return cout << "No\n", 0;
	for (int i = 1; i <= 2 * n - 1; i++)
		ans.push_back(i);
	int res = ans[n - 1];
	while (res != x) {
		int tmp = ans.back();
		ans.pop_back();
		ans.push_front(tmp);
		res = ans[n - 1];
	}
	cout << "Yes\n";
	for (auto i: ans)
		cout << i << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 2432
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] count = new int['Z'];
			count['A'] = scanner.nextInt();
			count['B'] = scanner.nextInt();
			count['C'] = scanner.nextInt();
			char[][] s = new char[n][];
			IntStream.range(0, n).forEach(i -> s[i] = scanner.next().toCharArray());
			List<String> answer = new ArrayList<>();
			boolean result = true;
			for (int i = 0; i < n; i++) {
				if (0 == count[s[i][0]] + count[s[i][1]]) {
					result = false;
					break;
				}
				if (count[s[i][0]] > count[s[i][1]]) {
					count[s[i][0]]--;
					count[s[i][1]]++;
					answer.add(String.valueOf(s[i][1]));
				} else if (count[s[i][0]] < count[s[i][1]]) {
					count[s[i][0]]++;
					count[s[i][1]]--;
					answer.add(String.valueOf(s[i][0]));
				} else {
					// count[s[i][0]] == count[s[i][1]]
					if (i < n - 1) {
						// 次のパターンで判定する
						if ((s[i][0] == s[i + 1][0]) && (s[i][1] == s[i + 1][1])) {
							// 次のパターンが同じとき
							count[s[i][0]]++;
							count[s[i][1]]--;
							answer.add(String.valueOf(s[i][0]));
						} else if ((s[i][0] == s[i + 1][0]) || (s[i][0] == s[i + 1][1])) {
							// 次のパターンと同じ文字のものを+1とする
							count[s[i][0]]++;
							count[s[i][1]]--;
							answer.add(String.valueOf(s[i][0]));
						} else {
							count[s[i][0]]--;
							count[s[i][1]]++;
							answer.add(String.valueOf(s[i][1]));
						}
					} else {
						count[s[i][0]]++;
						count[s[i][1]]--;
						answer.add(String.valueOf(s[i][0]));
					}
				}
			}
			System.out.println(result ? "Yes" : "No");
			if (result) {
				answer.forEach(System.out::println);
			}
		}
	}
}


Measured memory_bytes: 68276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

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

void solve() {
    int n;
    cin >> n;
    if(n == 0) exit(0);
    vector<pii> a(n);
    auto calc = [&](const string& s) {
        int ret = 0;
        rep(i, s.size()) if(s[i] != ':') {
            ret *= 10;
            ret += s[i] - '0';
        }
        return ret;
    };
    rep(i, n) {
        string s, t;
        cin >> s >> t;
        a[i].fi = calc(s);
        a[i].se = calc(t);
    }
    sort(all(a));
    int ans = 1;
    multiset<int> st;
    st.insert(a[0].se);
    REP(i, 1, n) {
        auto it = st.upper_bound(a[i].fi);
        if(it == st.begin()) ans++;
        else st.erase(--it);
        st.insert(a[i].se);
    }
    cout << ans << '\n';
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) solve();
    return 0;
}


Measured memory_bytes: 3368
#include <iostream>

int main() {
  int a, b, c, sum;
  std::cin >> a >> b >> c;
  sum = a + b + c;
  if (sum % 2 == 0 && (a + b == sum / 2 || a + c == sum / 2 || b + c == sum / 2)) {
    std::cout << "Yes";
  } else {
    std::cout << "No";
  }
}

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

int N;
int L[50];

bool check(int x,int y){
  map<int,bool> visited;
  queue<int> Q;
  Q.push(0);
  visited[0]=true;
  while(!Q.empty()){
    int p=Q.front();
    Q.pop();
    if(p==N)return true;
    int sum=0;
    for(int to=p+1;to<=N;to++){
      if(p==0 && to==N)continue;
      sum+=L[to-1];
      if(sum<x || y<sum)continue;
      if( !visited[to] ){
        visited[to]=true;
        Q.push(to);
      }
    }
  }
  return false;
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  
  vector<int> d;
  for(int i=0;i<N;i++){
    int sum=0;
    for(int j=i;j<N;j++){
      sum+=L[j];
      d.push_back(sum);
    }
  }
  
  for(int i=0;i<=1000;i++){
    for(int j=0;j<(int)d.size();j++){
      if( check(d[j],d[j]+i) ){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  return 0;
}



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

int main() {
    int r;
    cin >> r;
    if(r<1200){
        cout << "ABC" << endl;
    }
    else if(r>=1200 && r<2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#define MAXN 100001

int n, q, times[MAXN];
long long ans;

int main() {
	scanf("%d", &n);
	for (int i = 1, x; i <= n; ++i) {
		scanf("%d", &x);
		ans += x;
		++times[x];
	}
	scanf("%d", &q);
	for (int i = 1, b, c; i <= q; ++i) {
		scanf("%d %d", &b, &c);
		ans -= 1ll * times[b] * b;
		ans += 1ll * times[b] * c;
		printf("%lld\n", ans);
		times[c] += times[b];
		times[b] = 0;
	}
	return 0;
}

Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;
char s[3005];
int dp[3005][3005];
int main(){
    int n;
    scanf("%d", &n);
    scanf("%s", s+1);    
    for(int i=1;i<=n;i++){
        if(i == 1){
            for(int j=1;j<=n;j++) dp[i][j] = 1;
        }
        else{
            int num = n-i+1, sum = 0;
            if(s[i-1] == '>'){
                for(int j=1;j<=num+1;j++) sum = (sum + dp[i-1][j])%mod;
                for(int j=1;j<=num;j++){
                    sum = (sum - dp[i-1][j] + mod)%mod;
                    dp[i][j] = sum;
                }
            }
            else{
                for(int j=1;j<=num;j++){
                    sum = (sum + dp[i-1][j])%mod;
                    dp[i][j] = sum;
                }
            }
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++) ans = (ans + dp[n][i])%mod;
    printf("%d\n", ans);
}


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

using namespace std;

#define LL long int

const int MAX = 1e6;
const int MOD = 1e9+7;



int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    int count = 0;

    while(a >= b){
        b *= 2;
        count++;
    }

    while(b >= c){
        c *= 2;
        count++;
    }

    if(count <= k){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
# -*- coding:utf-8 -*-

def check(data):
    five_count = 0
    seven_count = 0

    for i in data:
        if i == 5:
            five_count += 1
        elif i == 7:
            seven_count += 1
    if five_count == 2 and seven_count == 1:
        return "YES"
    else:
        return "NO"

if __name__ == "__main__":

    A, B, C = map(int, input().split())

    print(check([A, B, C]))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI = (acos(-1));
const long long MOD = pow(10, 9) + 7;
long long kaizyou(int N);
long long POW(int J);

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

    int D[N][2];
    int judge[N] = {};
    bool flag = false;

    for(int i=0; i<N; i++)
    {
        cin >> D[i][0];
        cin >> D[i][1];

        if(D[i][0] == D[i][1])
        {
            judge[i] = 1;
        }
    }

        for(int i=0; i<N-2; i++)
        {
            if(judge[i] + judge[i+1] + judge[i+2] == 3)
            {
                flag = true;
                break;
            }
        }

        if(flag)
        {
            cout << "Yes";
        }else
        {
            cout << "No";
        }
        
    
}


Measured memory_bytes: 3620
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <set>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N;

int main() {
  // cout.precision(15);

  cin >> N;
  set<int> S{ 111, 222, 333, 444, 555, 666, 777, 888, 999 };
  loop(n,N,1000) {
    auto it = S.find(n);
    if (it == S.end()) continue;
    cout << *it << endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sz 21
#define ll long long int
using namespace std;

int dp[100000000];
vector<vector<int> > arr(sz+1);
int all;

void printarr(vector<vector<int> > arr){
    int i,j;
    cout<<"\nPrinting"<<endl;
    for(i=0;i<arr.size();i++){cout<<" i= "<<i<<" --->>> ";
        for(j=0;j<arr[i].size();j++){
            cout<<arr[i][j]<<" ";
        }cout<<endl;
    }
}

int ways(int mask, int j) {
    if(mask==all){
        return 1;
    }
    if(j==sz){
        return 0;
    }
    if(dp[mask]!=-1){
        return dp[mask];
    }
    ll res=0;
    for(int p:arr[j]){
        if((mask&(1<<p)) ==0){
            res=(res+ways((mask|(1<<p)), j+1))%mod;
        }
    }
    dp[mask]=res;
    return res;
}

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

    all=(1<<n)-1;
    memset(dp, -1, sizeof(dp));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int x;
            cin>>x;
            if(x==1){
                arr[i].push_back(j);
            }
        }
    }
    cout<<ways(0,0);
    return 0;
}


Measured memory_bytes: 390912
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
px = [list(map(int, input().split())) for x in range(m)]

for i in range(m):
    gokei = 0
    gokei = sum(t)-t[px[i][0]-1]+px[i][1]
    print(gokei)

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int L=1e6+1;
const LL M=1e9+7;

LL n;
LL md[L];
LL s(int i);
LL d(int i)
{
	if(md[i]>=0){
		return md[i];
	}
	if(i==0){
		return md[i]=1;
	}
	if(i==1){
		return n;
	}
	if(i==2){
		return md[i]=n*n%M;
	}

	LL v=d(i-1);
	(v+=s(i-3))%=M;
	(v+=(i-2)*(n-1)%M)%=M;
	(v+=(n+1-i)*n%M)%=M;
	return md[i]=v;

}
LL ms[L];
LL s(int i){
	if(ms[i]>=0){
		return ms[i];
	}
	if(i==0){
		return ms[i]=d(i);
	}
	return ms[i]=(s(i-1)+d(i))%M;
}

int bf(vector<int>& c, int s){
	if(c.size()==s){
		/*
		for(auto v:c){
			cerr << v;
		}
		cerr << endl;
		*/
		return 1;
	}
	int ret=0;
	for(int i=1;i<=n;i++){
		c.push_back(i);
		bool ok=true;
		for(int j=0;j<c.size()&&ok;j++){
			for(int k=j+1;k<min((int)c.size(),j+c[j]+1);k++){
				if(c[j+1]!=c[k]){
					ok=false;
					break;
				}
			}
		}
		if(ok){
			ret+=bf(c,s);
		}
		c.pop_back();
	}
	return ret;
}
int main() {
	memset(md,-1,sizeof(md));
	memset(ms,-1,sizeof(ms));
	cin >> n;
#if 0
	vector<int> v;
	for(int i=0;i<=n;i++){
		cerr << i << " " << bf(v,i) << " " << d(i) << endl; 
	}
#endif
	cout << d(n) << endl;

	return 0;
}



Measured memory_bytes: 47232
#include "bits/stdc++.h"
#define   LF      '\n'
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;


signed main()
{
  int N;
  cin >> N;
  for (int i = N; i < 1000; ++i) {
    char s[100];
    sprintf(s, "%d", i);

    if (s[0] == s[1] && s[0] == s[2]) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}



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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template
str s;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy\n";
    else if(s=="Cloudy")cout<<"Rainy\n";
    else if(s=="Rainy")cout<<"Sunny\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

int calc_count(int k, int K) {
  int score = k;
  int count = 0;
  while (score < K) {
    score *= 2;
    count++;
  }
  return count;
}

int main(void) {
  int N, K;
  std::cin >> N >> K;
  double prob = 0;
  int count1 = 0;
  for (int i = 1; i <= N; i++) {
    int count = calc_count(i, K);
    if (i == 1) {
      count1 = count;
      prob += 1;
    } else {
      prob += 1 << (count1 - count);
    }
  }
  std::cout << std::setprecision(12) << prob / (1 << count1) / N;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define exchange(a,b) {typeof(a) __tmp=a;a=b;b=__tmp;}
  
  
char A[100001];
int B[100001];
  
  
int Partition(int A[], int p, int r) {
  int i,j;
  int x;
  x = A[r];
  i = p-1;
  for(j = p; j < r; ++j) {
    if(B[A[j]] <= B[x]) { // if(A[j] <= x) {
      i = i+1;
      exchange(A[i], A[j]);
    }
  }
  exchange(A[i+1], A[r]);
  return i+1;
}
  
void Quicksort(int A[], int p, int r) {
  int q;
  if(p < r) {
    q = Partition(A,p,r);
    Quicksort(A,p,q-1);
    Quicksort(A,q+1,r);
  }
}
  
int isStable(int A[], int n) {
  int i;
  for(i = 2; i <= n; ++i) {
    if(B[A[i-1]] == B[A[i]] && A[i-1] > A[i]) return 0;
  }
  return 1;
}
  
int main() {
  int i;
  int n;
  int C[100001];
  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    scanf(" %c %d", A+i,B+i);
    C[i] = i;
  }
  Quicksort(C,1,n);
  if(isStable(C,n)) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 1; i <= n; ++i) {
    printf("%c %d\n", A[C[i]], B[C[i]]);
  }
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, p; cin >> n >> p;

	vl a(n);
	FOR(i,0,n) cin >> a[i];
	
	vvl dp(n+1,vl(2));
	dp[0][0] = 1;

	FOR(i,0,n) FOR(j,0,2) {
		dp[i+1][j] += dp[i][j];
		ll nj = j ^ (a[i] & 1);
		dp[i+1][nj] += dp[i][j];
	}
	cout << dp[n][p] << endl;
}



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

int Pfunc(int n) {
	int ans  =1;
	for (int i = 1; i <= n; i++)ans *= i;
	return ans;
}

int main() {

	int n;
	cin >> n;
	vector<int> P(n);
	vector<int> Q(n);
	vector<int> test(n);
	int p_cnt=0, q_cnt=0;

	for (int i = 0; i < n; i++)test[i] = i + 1;
	

	for (int i = 0; i < n; i++)cin >> P[i];
	for (int i = 0; i < n; i++)cin >> Q[i];


	for (int i = 0; i < n; i++)test[i] = i + 1;
	for (int i = 0; i < Pfunc(n); i++) {
		p_cnt++;
		
		if (P == test) {
			/*cout << p_cnt << endl;*/
			break;
		}
		next_permutation(test.begin(), test.end());
	}
	for (int i = 0; i < n; i++)test[i] = i + 1;
	for (int i = 0; i < Pfunc(n); i++) {
		q_cnt++;
		
		if (Q == test) {
			/*cout << q_cnt << endl;*/
			break;
		}
		next_permutation(test.begin(), test.end());
	}
	cout << abs(p_cnt - q_cnt) << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
const ll maxn = 310;
ll n,k,mod,c[maxn][maxn],f[maxn][maxn],sum[maxn][maxn];

int main()
{
    scanf("%lld%lld%lld",&n,&k,&mod);
    c[0][0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        c[i][0] = 1;
        for (ll j = 1; j <= i; j++)
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
    for (ll i = 0; i <= k; i++)
    {
        f[1][i] = 1;
        sum[1][i] = k - i + 1;
    }
    for (ll i = 2; i <= n + 1; i++)
    {
        for (ll j = 0; j <= k; j++)
            for (ll l = 1; l < i; l++)
                f[i][j] = (f[i][j] + 1LL * f[i - l][j] * sum[l][j + 1] % mod * c[i - 2][l - 1] % mod + mod) % mod;
        for (ll j = k; j >= 0; j--)
            sum[i][j] = (sum[i][j + 1] + f[i][j]) % mod;
    }
    printf("%lld\n",f[n + 1][0]);

    return 0;
}


Measured memory_bytes: 2432
N, X = map(int,input().split())
A = list(map(int,input().split()))

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

ans = abs(A[0]-X)
for a in A:
    ans = gcd(ans, abs(a-X))


print(ans)

Measured memory_bytes: 14224