akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        sc.close();
        int turu = -1;
        int kame = -1;
        kame = (y - 2*x) / 2;
        turu = (y - 4 * kame) / 2;
        if( y % 2 != 0 || turu + kame != x || turu < 0 || kame < 0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
        
        
    }
}


Measured memory_bytes: 35836
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()

	s := 0
	for i := 0; i < n; i++ {
		s += nextInt() - 1
	}

	fmt.Println(s)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int a, b;
    cin >> s;
    a = (s[0] - '0') * 10 + (s[1] - '0');
    b = (s[2] - '0') * 10 + (s[3] - '0');
    if(a > 12 || a < 1)
    {
        if(b > 12 || b < 1)
        {
            cout << "NA";
        }
        else
        {
            cout << "YYMM";
        }
    }
    else
    {
        if(b > 12 || b < 1)
        {
            cout << "MMYY";
        }
        else
        {
            cout << "AMBIGUOUS";
        }
    }

    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    if(n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes";
    else cout << "No";

    return 0;
}

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

using namespace std;

int main(void){
    int n,k;

    cin >> n >> k;
    vector<int> p(k, 0);
    int p_i = 0;

    int p_sum = 0;
    int max_sum = 0;
    for(int i=0; i<k; i++){
        cin >> p[i];
        p_sum += p[i];
        max_sum += p[i];
    }

    for(int i=k; i<n; i++){
        p_i = i % k;
        p_sum -= p[p_i];
        cin >> p[p_i];
        p_sum += p[p_i];
        max_sum = max(max_sum, p_sum);
    }

    double ans = (max_sum + k) / 2.0;

    printf("%.10lf\n", ans);

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    sort(items.begin(), items.end());
    ll cnt = 0;
    rep(i, N) {
        cnt += items[i].second;
        if (cnt >= K) {
            cout << items[i].first << '\n';
            return;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>

#define SIZE 50001

int hurui[SIZE];
int primeList[SIZE] = {0};

//エラトステネスのふるいを作る関数。	ついでにprimeListに素数のみを入れていき、素数の数を返す。	範囲はSIZE
int makeHurui(void);

//int check(int data[], int key, int from, int to);

int check02(int data[], int key, int pos, int to);

int main(){
	
	int i, k;
	int n;
	
	k = makeHurui();
	
	
	while(1){
		
		scanf("%d", &n);
		
		if(n == 0){
			
			break;
			
		}
		
		printf("%d\n", check02(primeList, n, 0, k));
		
	}
	
	
	/*
	for(i=4; i<=50000; i++){
		
		if(i % 5000 == 0){
			
			printf("-----------------------------------------\n");
			
		}
		
		printf("%d\n", check(primeList, i, 0, k));
		
	}
	*/
	
	return 0;
	
}


int makeHurui(void){
	
	int i, k;
	int m = 0;
	
	for(i=0; i<SIZE; i++){
		
		hurui[i] = 1;
		
	}
	
	hurui[0] = 0;
	hurui[1] = 0;
	
	for(i=2; i<SIZE; i++){
		
		if(hurui[i] == 1){
			
			for(k=i+i; k<SIZE; k+=i){
				
				hurui[k] = 0;
				
			}
			
			
			primeList[m] = i;
			m++;
			
		}
		
	}
	
	return m;
	
}
/*
int check(int data[], int key, int from, int to){
	
	int i;
	int count = 0;
	
	if(data[from] > key/2){
		
		return 0;
		
	}
	
	for(i=from; i<to; i++){
		
		if(key == data[from] + data[i]){
			
			printf("%d, %d\n", data[from], data[i]);
			
			count++;
			break;
			
		}
		
	}
	
	return count + check(data, key, from+1, to);
	
}
*/

int check02(int data[], int key, int pos, int to){
	
	int count = 0;
	
	if(data[pos] > key/2){
		
		return 0;
		
	}
	
	if(hurui[key - data[pos]] == 1){
		
		count++;
		//printf("%d, %d\n", data[pos], key-data[pos]);
		
	}
	
	return count + check02(data, key, pos+1, to);
	
}

Measured memory_bytes: 820
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a<b && b<c){printf("Yes\n");}
	else{printf("No\n");}
	
	return(0);
}

	

Measured memory_bytes: 580
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

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

    int n,m;
    int ac = 0,wa = 0;
    cin >> n >> m;

    vector<bool> flg(n+1);
    vector<int> cnt(n+1);

    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC"){
            if(!flg[p]){
                flg[p] = true;
            }
        }else{
            if(!flg[p]){
                cnt[p]++;
            }
        }
    }

    reps(i,n){
        if(flg[i]){
            ++ac;
            wa += cnt[i];
        }
    }

    cout << ac << ' ' << wa << '\n';

    return 0;
}


Measured memory_bytes: 1024
{-# LANGUAGE RecursiveDo        #-}
{-# LANGUAGE BangPatterns       #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE NumericUnderscores #-}

import Control.Monad
import Data.List
import Data.Char
import qualified Data.ByteString.Char8 as C8

spendOneDay :: [Int] -> [Int] -> [Int]
spendOneDay [a, b, c] [d, e, f] = [h, i, j]
  where h = max (b + d) (c + d)
        i = max (a + e) (c + e)
        j = max (a + f) (b + f)

main = do
  n <- readLn
  h <- replicateM n $ unfoldr (C8.readInt . C8.dropWhile isSpace) <$> C8.getLine
  print $ maximum $ foldl spendOneDay [0, 0, 0] h


Measured memory_bytes: 51964
s = input()
for i in range(2 ** 3):
    ans = s[0]
    for j in range(3):
        if ((i >> j) & 1):
            ans += "+" + s[j + 1]
        else:
            ans += "-" + s[j + 1]

    if eval(ans) == 7:
        print(ans + "=7")
        exit()

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;

//
class Node {
private:
	int key;
	Node *p_next = NULL;
	Node *p_prev = NULL;
public:
	Node(int k);
	void linkNext(Node *n);
	void linkPrev(Node *n);
	Node *getNext();
	Node *getPrev();
	bool hasKey(int k);
	void printKey();
};

Node::Node(int k)
{
	key = k;
}

void Node::linkNext(Node *p_n)
{
	p_next = p_n;
}

void Node::linkPrev(Node *p_n)
{
	p_prev = p_n;
}

Node *Node::getNext()
{
	return p_next;
}

Node *Node::getPrev()
{
	return p_prev;
}

bool Node::hasKey(int k)
{
	return key == k;
}

void Node::printKey()
{
	cout << key;
}

//
class LinkedList {
private:
	Node *p_dummy;
	void linkNode(Node *p_n1, Node *p_n2);
public:
	LinkedList();
	void insertNode(int key);
	void deleteNode(int x);
	void deleteFirst();
	void deleteLast();
	void print();
};

LinkedList::LinkedList()
{
	p_dummy = new Node(-1);
	linkNode(p_dummy, p_dummy);
}

void LinkedList::linkNode(Node *p_n1, Node *p_n2)
{
	p_n1->linkNext(p_n2);
	p_n2->linkPrev(p_n1);
}

void LinkedList::insertNode(int key)
{
	Node *p_n = new Node(key);
	linkNode(p_n, p_dummy->getNext());
	linkNode(p_dummy, p_n);
}

void LinkedList::deleteNode(int x)
{
	Node *p_n = p_dummy->getNext();
	while (!p_n->hasKey(x)) {
		if (p_n->hasKey(-1)) return;
		p_n = p_n->getNext();
	}
	
	linkNode(p_n->getPrev(), p_n->getNext());
	delete p_n;
}

void LinkedList::deleteFirst()
{
	linkNode(p_dummy, p_dummy->getNext()->getNext());
}

void LinkedList::deleteLast()
{
	linkNode(p_dummy->getPrev()->getPrev(), p_dummy);
}

void LinkedList::print()
{
	Node *p_n = p_dummy->getNext();
	if (p_n->hasKey(-1)) return;
	while (1) {
		p_n->printKey();
		p_n = p_n->getNext();
		if (p_n->hasKey(-1)){
			cout << endl;
			break;
		} else {
			cout << " ";
		}
	}
}

//
int main(void)
{	
	LinkedList list;
	
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		char command[12] = "\0";
		cin >> command;
		if (strcmp(command, "insert") == 0) {
			int key;
			cin >> key;
			list.insertNode(key);
		} else if (strcmp(command, "delete") == 0) {
			int key;
			cin >> key;
			list.deleteNode(key);
		} else if (strcmp(command, "deleteFirst") == 0) {
			list.deleteFirst();
		} else {
			list.deleteLast();
		}
	}

	list.print();
	
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();

  vector<ll> v;
  for (int i = 1; i <= 9; i++) v.push_back(i);

  int done = 0;
  while ((int)v.size() < N) {
    int M = v.size();
    for (; done < M; done++) {
      const ll x = v[done];
      int l = x % 10;
      for (int i = l-1; i <= l+1; i++) if (0 <= i && i <= 9) {
        v.push_back(x * 10 + i);
      }
    }
    sort(ALL(v));
  }
  cout << v[N-1] << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

struct Data{
	int num;
	struct Data *next;
};

struct Data *data;

void Make_list(void);
struct Data* New_list(void);
void Enqueue(int);
int Dequeue(void);
void BFS(int);

int *d;
char *color;
int n;
int *queue;
int head,tail;

int main(void){
	int i;

	scanf("%d",&n);

	d=(int*)malloc(sizeof(int)*(n+1));
	color=(char*)malloc(sizeof(char)*(n+1));
	queue=(int*)malloc(sizeof(int)*(n));
	data=(struct Data*)malloc(sizeof(struct Data)*(n+1));

	for(i=1;i<=n;i++) Make_list();

	BFS(1);

	for(i=1;i<=n;i++) printf("%d %d\n",i,d[i]);

	free(d);
	free(color);
	free(queue);

	return 0;
}


void Make_list(void){
	int edg,ver,num;
	int i;
	struct Data *work;

	scanf("%d",&ver);
	scanf("%d",&edg);

	data[ver].num=ver;
	data[ver].next=NULL;

	work=&data[ver];

	for(i=0;i<edg;i++){
		work->next=New_list();
		work=work->next;
	}
}


struct Data* New_list(void){
	struct Data *new;

	new=(struct Data*)malloc(sizeof(struct Data));

	scanf("%d",&new->num);
	new->next=NULL;

	return new;
}



void BFS(int s){
	int i;
	int u;
	struct Data *work;

	for(i=s;i<=n;i++){
		d[i]=-1;
		color[i]='w';
	}
	for(i=0;i<n;i++) queue[i]=-1;
	head=0;
	tail=0;

	color[s]='g';
	d[s]=0;

	Enqueue(s);
	while(head!=tail){
		u=Dequeue();
		work=&data[u];
		while(work->next != NULL){
			work=work->next;
			if(color[work->num]=='w'){
				color[work->num]='g';
				d[work->num]=d[u]+1;
				Enqueue(work->num);
			}
		}
		color[u]='b';
	}
}


void Enqueue(int num){
	queue[tail]=num;
	tail++;
	if(tail>=n) tail=0;
}


int Dequeue(){
	int num;

	num=queue[head];
	head++;
	if(head>=n) head=0;
	return num;
}

Measured memory_bytes: 608
import sys
def LI():
    return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def S(): 
    return sys.stdin.readline().rstrip()

H,W = LI()

print(''.join(['#']*(W+2)))

for i in range(H):
    print('#' + S() + '#')

print(''.join(['#']*(W+2)))

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  mint ans = 0;
  REP(i,62){
    int32 cnt = 0;
    REP(j,n){
      cnt += (a[j] & 1);
      a[j] >>= 1;
    }
    ans += mint(cnt) * (n-cnt) * (1ll << i);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 2560
function MainC(input){
    const N = Number(input);
    let answer = 0;
    for(let A=1; A<N; A++){
        for(let B=1; B<N/A; B++){
            answer++;
        }
    }
    console.log(answer);
}
MainC(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 32548
#include <stdio.h>
#include <math.h>
int main(){
  double r,ans1,ans2;
  scanf("%lf",&r);
  ans1 = r * 2 * M_PI;
  ans2 = r * r * M_PI;
  printf("%f %f\n",ans2,ans1);
  return 0;
}

Measured memory_bytes: 1852
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (N,K) = readPair int int ()
let D = reads int () |> Array.map (fun x -> char (x + int '0'))

seq { N..100000 }
|> Seq.filter (fun n->
  let s = (string n).ToCharArray() |> Set.ofArray
  D |> Array.forall (not << (fun c -> s |> Set.contains c))
)
|> Seq.head
|> printfn "%d"

Measured memory_bytes: 19128
# -*- coding: utf-8 -*-
"""
Created on Mon May  4 14:09:04 2020

@author: Kanaru Sato
"""

import sys
sys.setrecursionlimit(10**9)

n,m = list(map(int, input().split()))
thisconnected = [[] for i in range(n+1)]
thismemo = [-1 for i in range(n+1)]

for i in range(m):
    x,y = list(map(int, input().split()))
    thisconnected[x].append(y)

def lp(k,memo,connected):
    if memo[k] != -1:
        return memo[k]
    elif not connected[k]:
        memo[k] = 0
        return 0
    else:
        res = -1
        for point in connected[k]:
            if res < lp(point,memo,connected):
                res = lp(point,memo,connected)
        memo[k] = res+1
        return res+1

for i in range(1,n+1):
    if thismemo[i] == -1:
        thismemo[i] = lp(i,thismemo,thisconnected)

print(max(thismemo))

Measured memory_bytes: 65224
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** problem1137 : Numeral System **/
int toNum(string s)
{
	int p=0;
	int ret=0;
	while (p<s.size()) {
		int m=1;
		
		if (isdigit(s[p])) {
			m = s[p]-'0';
			p++;
		}
		
		if (s[p] == 'm')
			ret += m*1000;
		if (s[p] == 'c')
			ret += m*100;
		if (s[p] == 'x')
			ret += m*10;
		if (s[p] == 'i')
			ret += m;
		
		p++;
	}
	return ret;
}

string toMCXI(int n)
{
	string ret;
	
	int m=0;
	while (n>=1000) {
		n-=1000; m++;
	}
	if (m>1) {
		ret += m+'0';
		ret += 'm';
	} else if (m==1)
		ret += 'm';
	
	m=0;
	while (n>=100) {
		n-=100; m++;
	}
	if (m>1) {
		ret += m+'0';
		ret += 'c';
	} else if (m==1)
		ret += 'c';
	
	m=0;
	while (n>=10) {
		n-=10; m++;
	}
	if (m>1) {
		ret += m+'0';
		ret += 'x';
	} else if (m==1)
		ret += 'x';
	
	m=0;
	while (n>=1) {
		n-=1; m++;
	}
	if (m>1) {
		ret += m+'0';
		ret += 'i';
	} else if (m==1)
		ret += 'i';
	
	return ret;
}

int main()
{
	int N; cin>>N;
	rep(i, N) {
		string a, b;
		cin>>a>>b;
		int sum = toNum(a) + toNum(b);
		cout << toMCXI(sum) << endl;
	}
}

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

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

using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}
typedef pair<int,int> P;
vector<vector<int>>  d(30, vector<int>(30,10000000));
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};

//スタートの位置だけ決め、各点までの最短距離のmaxを記録　そのmaxを求める
int bfs(int sx,int sy,int H,int W, vector<vector<char>> &maze){
   queue<P> que;
    que.push(P(sx,sy));
    d[sx][sy] = 0;
    int res = d[sx][sy];
    
    while(que.size()){
    
   P p = que.front();
   que.pop();
   
    for(int i = 0;i<4;i++){
     int nx = p.first + dx[i],ny = p.second + dy[i];
     
     if(0<=nx && nx <H && 0<=ny && ny <W && maze[nx][ny] != '#' 
         && d[nx][ny] == 10000000){
         que.push(P(nx,ny));
         d[nx][ny] = d[p.first][p.second] + 1;
         res = max(res,d[nx][ny]);
        }
       }
      }
      return res;
     }

int main(){
  string S,T;
  cin >> S >> T;
  string ans = T+S;
  cout << ans << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    rep(i, 0, N) {
        int h;
        cin >> h;
        if (h >= K) {
            ans++;
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



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


using namespace std;

int main(){

int N;
int x[101];
int y[101];
int h[101];

int calc_h;
int check_h;
int check_N = 0;
int xt,yt,ht;
int cx,cy,H;

cin >> N;

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

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

if(h[i] > 0){
xt = x[i];
yt = y[i];
ht = h[i];
}
}



for(int j = 0; j <101 ; ++j){
for(int k = 0; k <101 ; ++k){

calc_h = ht+abs(xt-j)+abs(yt-k);

for(int i = 0; i < N; ++i){
check_h = max(calc_h-abs(x[i]-j)-abs(y[i]-k),0);

if(check_h == h[i]){
check_N = check_N+1;
}
}

if(check_N == N){
cx = j;
cy = k;
H = calc_h;
}else{
check_N = 0;
}

}
}

cout << cx << " " << cy << " " << H << endl;

}

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

int main(){
  string s, t;
  cin >> s >> t;
  if (s.size() <= t.size() &&
      equal(begin(s), end(s), begin(t))) {
     cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;

  
  return 0;
}

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

int A, B, Q; 
const long long X_MAX = 1e10;
vector<long long> s, t;
const long long INF = 1ull << 60;

int main() {
  cin >> A >> B >> Q;
  s.resize(A + 2); t.resize(B + 2);
  s[0] = -(INF + 1);
  s[A + 1] = (INF + 1);
  for(int i = 1; i <= A; i++){
    cin >> s[i];
  }
  t[0] = -(INF + 1);
  t[B + 1] = (INF + 1);
  for(int i = 1; i <= B; i++){
    cin >> t[i];
  }
  for(int i = 0; i < Q; i++){
    long long x; cin >> x;
    auto s_it = lower_bound(s.begin(), s.end(), x);
    auto t_it = lower_bound(t.begin(), t.end(), x);
    long long res = INF;
    res = min(res, abs(*s_it - x) + abs(*t_it - *s_it));
    res = min(res, abs(*t_it - x) + abs(*t_it - *s_it));
    s_it--;
    res = min(res, abs(*s_it - x) + abs(*t_it - *s_it));
    res = min(res, abs(*t_it - x) + abs(*t_it - *s_it));
    t_it--;
    res = min(res, abs(*s_it - x) + abs(*t_it - *s_it));
    res = min(res, abs(*t_it - x) + abs(*t_it - *s_it));
    s_it++;
    res = min(res, abs(*s_it - x) + abs(*t_it - *s_it));
    res = min(res, abs(*t_it - x) + abs(*t_it - *s_it));
    
    cout << res << endl;
  }
  
}

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

d = {}
for e in A:
    if e not in d:
        d[e] = 1
    else:
        d[e] = d[e] + 1

edges = []
for k, v in d.items():
    if v >= 4:
        edges.append(k)
        edges.append(k)
    elif v >= 2:
        edges.append(k)

if len(edges) <= 1:
    print(0)
else:
    edges.sort()
    print(edges[-1] * edges[-2])


Measured memory_bytes: 67608
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    VLL A(N);
    vector<vector<ll>> x(N);
    vector<vector<ll>> y(N);
    ll ans=0;
    rep(i,N){
        cin >> A[i];
        rep(j,A[i]){
            ll x_i,y_i;
            cin >> x_i >> y_i;
            x[i].PB(x_i);
            y[i].PB(y_i);
        }
    }
    for(int i=0; i<(1<<N); i++){
        bitset<15> person(i);
        ll honest_person=0;
        rep(j,N){
            if(person.test(j)){
                honest_person++;
            }
        }
        bool judge=true;
        rep(j,N){
            if(person.test(j)){
                rep(k,A[j]){
                    if(y[j][k]==0){
                        if(person.test(x[j][k]-1)) judge=false;
                    }
                    if(y[j][k]==1){
                        if(!person.test(x[j][k]-1)) judge=false;
                    }
                }
            }
        }
        if(judge) ans=max(ans,honest_person);
    }
    cout << ans << endl;   
}

Measured memory_bytes: 3672
import numpy as np
#s = "1234567"
s = input()
#print(len(s))

ss = []

for i in range(len(s)-2):
    #print(s[i:i+3])
    ss.append(int(s[i:i+3]))

ss = np.array(ss)
print(np.abs((ss - 753)).min())

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

int main()
{
	int i,a,b;
	double aa,bb;
	scanf("%d%d",&a,&b);
	for (i=1;i<=100000;i++)
	{
		aa=i*0.08;
		bb=i*0.10;
		if (floor(aa)==a&&floor(bb)==b)
		{
			printf("%d",i);
			return 0;
		}
	}
	
	printf("-1");
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

vector<int> X;
int ans;
int D[13];

void calc(){
    int tmp = 24;
    int size = X.size();
    REP(i,size){
        int x = X[i];
        REPi(j,i+1,size){
            int y = X[j];
            int diff = abs(x-y);
            chmin(tmp, min(diff, 24-diff));
        }
    }
    chmax(ans, tmp);
}

void dfs(int idx){
    if(idx == 13){
        calc();
        return;
    }

    int d = D[idx];
    if(idx == 0 || idx == 12){
        if(d == 0)
            dfs(idx+1);
        else if(d == 1){
            X.push_back(idx);
            dfs(idx+1);
            X.pop_back();
        }
        else if(d == 2){
            X.push_back(idx);
            X.push_back(idx);
            dfs(idx+1);
            X.pop_back();
            X.pop_back();
        }
    }
    else{
        if(d == 0)
            dfs(idx+1);
        else if(d == 1){
            X.push_back(idx);
            dfs(idx+1);
            X.pop_back();

            X.push_back(24-idx);
            dfs(idx+1);
            X.pop_back();
        }
        else if(d == 2){
            X.push_back(idx);
            X.push_back(24-idx);
            dfs(idx+1);
            X.pop_back();
            X.pop_back();
        }
    }
}

int main(){
    int N;
    cin >> N;
    bool zero = false;
    D[0]++;
    REP(i,N){
        int d;
        cin >> d;
        D[d]++;
        if(D[d] == 3){
            zero = true;
        }
    }

    if(zero){
        cout << 0 << endl;
        return 0;
    }

    ans = 0;
    dfs(0);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
string a,b,c;
ll MOD=1000000007;
int main(){
	while(cin>>a,a!="0"){
		cin>>b>>c;
		ll now[2]={1,0};
		for(int q=a.size()-1;q>=0;q--){
			ll next[2]={0,0};
			rep(i,10)rep(j,10)rep(k,10)rep(l,2){
				if(a[q]!='?'&&a[q]-'0'!=i)continue;
				if(b[q]!='?'&&b[q]-'0'!=j)continue;
				if(c[q]!='?'&&c[q]-'0'!=k)continue;
				if(!(q||i&&j&&k))continue;
				if((i+j+l)%10==k){
					if(i+j+l>=10)(next[1]+=now[l])%=MOD;
					else (next[0]+=now[l])%=MOD;
				}
			}
			now[0]=next[0];
			now[1]=next[1];
//			cout<<now[0]<<" "<<now[1]<<endl;
		}
		cout<<now[0]<<endl;
	}
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int r = 100;
int c = 100;
char grid[120][120];
void assignrow(int i)
{
	for (int j = 0; j < c; j++) grid[i][j] = '.';
}
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	assignrow(0);
	bool swapped = false;
	if (a < b)
	{
		swapped = 1;
		swap(a, b);
	}
	a--;
	b--;
	for (int i = 2; i < r && b; i+=2)
	{
		assignrow(i);
		b--;
		if (!b) a--;
		for (int j = 1; j < c-1 && b; j+=2)
		{
			b--;
			grid[i-1][j] = '.';
		}
	}
	while (a)
	{
		int x, y;
		x = rand()%r;
		y = rand()%c;
		if (!x || !y || x == r-1 || y == c-1) continue;
		bool works = 1;
		for (int i = -1; i <= 1; i++)
		{
			for (int j = -1; j <= 1; j++)
			{
				if (grid[x+i][y+j]) works = 0;
			}
		}
		if (works)
		{
			a--;
			grid[x][y] = '.';
		}
	}	
	printf("%d %d\n", r, c);
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			if (!swapped)
			{
				if (grid[i][j] == '.') printf(".");
				else printf("#");
			}
			else
			{
				if (grid[i][j] != '.') printf(".");
				else printf("#");
			}
		}
		printf("\n");
	}	
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int i,a=0,j,l,c=0,n,num[10000],q,qnum[500];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }

  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&qnum[j]);
  }

  
  for(j=0;j<q;j++){
    for(i=0;i<n;i++){
      if(num[i] == qnum[j]) {
	c++;
	break;
      }
    }
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

vi adj[100001];
int dp[100001][2];

int dfs(int x, int p, bool b)
{
    if (dp[x][b] != -1) return dp[x][b];
    int wp = 1, bp = 1;
    for (int y : adj[x])
    {
        if (y == p) continue;
        muls(wp, dfs(y, x, false));
        muls(bp, dfs(y, x, true));
    }
    return dp[x][b] = b ? wp : add(bp, wp);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
    {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    memset(dp, -1, sizeof dp);
    cout << dfs(1, -1, false);
}


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

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (2 * n > m) {
        cout << m / 2 << endl;
        return 0;
    } else {
        ans += n;
        m -= 2 * n;
    }
    cout << ans + m / 4 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3005;
typedef long double db;
typedef long long ll;
const db pi=acos(-1.0);
int n,L,a[maxn];
ll w;
db x,y,X,Y;
int main(){
    cin >> n >> L;
    for (int i=1;i<=n;i++) cin >> a[i];
    sort(a,a+n);
    for (int i=1;i<=n;i++)
    for (int j=i+1;j<=n;j++){
        x=cos(pi*(a[i]+a[j])/L);
        y=sin(pi*(a[i]+a[j])/L);
        int r=((n-2)-(j-i-1))-(j-i-1);
        X+=x*r; Y+=y*r;
    }
    w=1ll*n*(n-1)*(n-2)/6;
    printf("%.15Lf %.15Lf\n",X/w,Y/w);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
int main()
{
	boost
	string s,t;
	cin>>s>>t;
	ll ans=0;
	for(ll i=0; i<s.size(); i++)
		if(s[i]==t[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>n;
    cout << arr[n-1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = n / 1000;
        if(n % 1000 != 0){
            x++;
        }
        System.out.println(x * 1000 - n);

    }
}


Measured memory_bytes: 35768
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll g = __gcd(a,b);
	ll m=g;
	ll res=1;
	for(ll i=2;i*i<=m;i++){
		if(g%i==0){
			res++;
		}
		while(g%i==0){
			g/=i;
		}
	}
	if(g>1){
		res++;
	}
	cout<<res<<"\n";
}


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

int main(){
  int h,w;
  cin>> h >> w;
  char c;
  vector<vector<bool>> map(h,vector<bool>(w));
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      cin>> c;
      if (c=='.') map.at(i).at(j)=true;
    }
  }
  
  vector<vector<int>> light(h,vector<int>(w));
  for (int i=0; i<h; i++){ //横方向の計算
    for(int l=0; l<w; l++){
      if (map.at(i).at(l)){
        int r=l+1;
        while (r<w && map.at(i).at(r)) r++;
        for (int k=l; k<r; k++) light.at(i).at(k)+=r-l;
        l=r;
      }
    }
  }
  for (int i=0; i<w; i++){ //縦方向の計算
    for(int l=0; l<h; l++){
      if (map.at(l).at(i)){
        int r=l+1;
        while (r<h && map.at(r).at(i)) r++;
        for (int k=l; k<r; k++) light.at(k).at(i)+=r-l-1; //1重複するので引く
        l=r;
      }
    }
  }
  
  int ans=0;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      ans=max(ans,light.at(i).at(j));
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 16512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();

		if(a < b) {
			if(b - (a + W) > 0) {
				int ans = b - (a + W);
				System.out.println(ans);
				return;
			}else {
				System.out.println(0);
				return;
			}
		}else if(a > b) {
			if(a - (b + W) > 0) {
				int ans = a - (b + W);
				System.out.println(ans);
				return;
			}else {
				System.out.println(0);
				return;
			}
		}else {
			System.out.println(0);
		}
	}

}

Measured memory_bytes: 21588
from collections import defaultdict
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
cnt=defaultdict(lambda :0)
for i in range(m):
    cnt[ab[i][0]]+=1
    cnt[ab[i][1]]+=1

for i in cnt.values():
    if i%2!=0:
        print('NO')
        exit()
print('YES')

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

int main() {
  string N;
  cin >> N;
  int count = 0;
  
  
  for (int i = 0; i < N.size(); i++) {
    if (N.at(2) == N.at(1) && N.at(1) == N.at(i)) {
      count++;
    }
  }
  if (count >= 3) {
    cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }
  
      
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int X=gi();

	    while(true) {
	    	boolean flg=true;
	        for (int i=2; i<Math.floorDiv(X, 2);i++) {
	        	if(X%i==0) {
	        		flg=false;
	        		break;
	        	}
	        }
	        if(flg)break;
	        X++;
	    }

        System.out.print(X);
//        if (s.charAt(0)=='0' && N!=1) {
//        	System.out.println(-1);
//        }else {
//        	System.out.println(s);
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35820
#include <algorithm>
#include <iostream>
#include <vector>
#include <complex>
#include <cmath>
#include <set>
using namespace std;

const double PI = acos(-1);
const complex<double> I(0, 1);
typedef complex<double> Complex;

namespace std {
    bool operator<(const Complex& a, const Complex& b) {
        return make_pair(a.imag(), a.real()) < make_pair(b.imag(), b.real());
    }
}

enum class EventType {
    LINE_BEGIN, LINE_END, PASSENGER,
};

struct Event {
    double y;
    EventType type;
    int index;

    bool operator<(const Event& other) const {
        return y > other.y;
    }
};

// 時計回りに45度回転
Complex rotated(const Complex& p) {
    return p * exp(-I * PI * 0.25);
}

int main() {
    int N, Q;
    while (cin >> N >> Q) {
        vector<Event> events;
        vector<Complex> ps;
        for (int i = 0; i < N; ++i) {
            double S, T, X;
            cin >> S >> T >> X;
            ps.push_back(Complex(S - 0.5, X));
            Complex p1 = rotated(Complex(S - 0.5, X));
            Complex p2 = rotated(Complex(T - 0.5, X));
            events.push_back({ p1.imag(), EventType::LINE_BEGIN, i });
            events.push_back({ p2.imag(), EventType::LINE_END, i });
        }

        for (int i = 0; i < Q; ++i) {
            double D; cin >> D;
            Complex p = rotated(Complex(D, 0));
            events.push_back({ p.imag(), EventType::PASSENGER, i });
        }

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

        vector<double> answers(Q, -1);
        set<Complex> crossing;
        for (const Event& e : events) {
            switch (e.type) {
                case EventType::LINE_BEGIN: {
                    Complex p = ps[e.index];
                    crossing.insert(p);
                    break;
                }
                case EventType::LINE_END: {
                    Complex p = ps[e.index];
                    crossing.erase(p);
                    break;
                }
                case EventType::PASSENGER: {
                    if (crossing.empty()) break;
                    Complex p = *crossing.begin();
                    answers[e.index] = p.imag();
                    break;
                }
            }
        }

        for (double a : answers) {
            cout << (long long)round(a) << '\n';
        }
    }
}

Measured memory_bytes: 29524
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
  int n = in(),x = in();
  VI a(n);
  REP(i,n) a[i] = in();
  a.push_back(x);
  sort(ALL(a));
  int ans = a[1] - a[0];
  REP(i,n){
    ans = __gcd(ans, a[i+1] - a[i]);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1024