akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAX=2003;
const int MOD=1000000007;
int N,K,Q,A[MAX];
vector<pii> arr;
queue<pii> rng;
vector<int> det[MAX];
priority_queue<pii> seg;
int ans=MOD,pos[MAX],pt[MAX];
main(){
    scanf(" %d %d %d",&N,&K,&Q);
    for(int i=0;i<N;i++) scanf(" %d",&A[i]), arr.push_back(make_pair(A[i],i));
    sort(arr.begin(),arr.end());
    rng.push(make_pair(0,N));
    for(int i=0;i<N;i++){
        int fin=0;
        for(int j=0;j<=i;j++){
            pii tmp=rng.front();
            rng.pop();
            rng.push(tmp);
            det[j].clear();
            for(int k=tmp.first;k<tmp.second;k++) det[j].push_back(A[k]);
            sort(det[j].begin(),det[j].end());
            pos[j]=tmp.second-tmp.first-K+1; pt[j]=0;
            if(pos[j]>0) seg.push(make_pair(-det[j][0],j));
        }
        int mmin=MOD,mmax=0;
        for(int j=0;j<Q;j++){
            if(seg.empty()){
                fin=1;
                break;
            }
            pii tmp=seg.top();
            seg.pop();
            mmin=min(-tmp.first,mmin);
            mmax=-tmp.first;
            pt[tmp.second]++;
            //printf("%d %d %d %d\n",tmp.first,tmp.second,pt[tmp.second],pos[tmp.second]);
            if(pt[tmp.second]<pos[tmp.second]) seg.push(make_pair(-det[tmp.second][pt[tmp.second]],tmp.second));
        }
        if(fin) break;
        ans=min(ans,mmax-mmin);
        while(!seg.empty()){seg.pop();}
        for(int j=0;j<=i;j++) {
            pii tmp=rng.front();
            rng.pop();
            if(tmp.first<=arr[i].second&&arr[i].second<tmp.second){
                rng.push(make_pair(tmp.first,arr[i].second));
                rng.push(make_pair(arr[i].second+1,tmp.second));
            }
            else rng.push(tmp);
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 8832
input = readlines()

n = input.shift.chomp.to_i

is_ok = true
input.shift.chomp.split("\s").map{|x| x.to_i}.each do |item|
  next if item.odd?
  is_ok = false if item % 3 > 0 && item % 5 > 0
end

puts is_ok ? 'APPROVED' : 'DENIED'

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

using namespace std;

int sumDigits(int x) {
    int res = 0;
    for (int i = 0; i < 5; i++) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    int counter = 0;
    for (int i = 1; i <= N; i++) {
        int sum = sumDigits(i);
        if (A <= sum && sum <= B) {
            counter+=i;
        }
    }
    cout<<counter<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let A: usize = read();
    let B: usize = read();
    println!("{}", lcm(A, B));
}

fn gcd(a: usize, b: usize) -> usize {
    let mut a = a;
    let mut b = b;
    if a < b {
        std::mem::swap(&mut a, &mut b);
    }
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn lcm(a: usize, b: usize) -> usize {
    a * b / gcd(a, b)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_gcd() {
        assert_eq!(gcd(12, 15), 3);
    }

    #[test]
    fn test_lcm() {
        assert_eq!(lcm(5, 10), 10)
    }
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int main(){
  while(true){
    int w,h;
    cin>>h>>w;
    string rec;
    if(w==h&&w==0)
      break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	rec+="#";
      }
      rec+="\n";
    }
    cout<<rec<<endl;
  }
}



Measured memory_bytes: 3068
#include <iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s.length() % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < s.length(); i++) {
		if (i % 2 == 0 && s[i] != 'h') {
			cout << "No" << endl;
			return 0;
		}
		if (i % 2 == 1 && s[i] != 'i') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, a, b int
	fmt.Scanf("%d %d %d", &n, &a, &b)
	total := 0
	for i := 1; i <= n; i++ {
		s := strconv.Itoa(i)
		sum := 0
		for l := 0; l < len(s); l++ {
			tmp, _ := strconv.Atoi(string(s[l]))
			sum += tmp
		}
		if (sum >= a) && (sum <= b) {
			total += i
		}
	}
	fmt.Println(total)
}


Measured memory_bytes: 1868
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij=[(1,0),(0,1),(-1,0),(0,-1)]

def main():
    h,w=MI()
    ss=[SI() for _ in range(h)]

    def dfs(i,j):
        stack=[(i,j)]
        bc,wc=0,0
        while stack:
            i,j=stack.pop()
            if ss[i][j]=="#":bc+=1
            else:wc+=1
            for di,dj in dij:
                ni,nj=i+di,j+dj
                if ni<0 or nj<0 or ni>=h or nj>=w:continue
                if fin[ni][nj] or ss[i][j]==ss[ni][nj]:continue
                fin[ni][nj]=True
                stack.append((ni,nj))
        return bc,wc

    ans=0
    fin=[[False]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if fin[i][j]:continue
            fin[i][j]=True
            bc,wc=dfs(i,j)
            ans+=bc*wc
    print(ans)

main()

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

typedef pair<int, int> pii;

int N, M;
vector<pii> adj[402];
int chk[402][402], vis[402], del[402];
int ans;

bool dfs(int u, int fe, int st) {
    chk[st][u] = 1;
    vis[u] = 1;

    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i].first;
        int e = adj[u][i].second;
        if(e >= fe) continue;
        if(vis[v]) return false;
        if(!dfs(v, e, st)) return false;
    }
    return true;
}

int main() {
    scanf("%d %d", &N, &M);

    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }
    for(int i = 0; i < N; i++) {
        memset(vis, 0, sizeof(vis));
        if(!dfs(i, 1e9, i)) del[i] = 1;
    }
    for(int i = 0; i < N; i++) {
        if(del[i]) continue;
        for(int j = i + 1; j < N; j++) {
            if(del[j]) continue;

            bool ok = true;
            for(int k = 0; k < N; k++) if(chk[i][k] && chk[j][k]) {
                ok = false;
                break;
            }
            if(ok) ans++;
        }
    }

    printf("%d", ans);
}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long LLINF = LL(99999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    double x1, y1;
    double x2, y2;
    double x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double edge1 = sqrt(pow(abs(x1-x2),2)+pow(abs(y1-y2),2));
    double edge2 = sqrt(pow(abs(x2-x3),2)+pow(abs(y2-y3),2));
    double edge3 = sqrt(pow(abs(x3-x1),2)+pow(abs(y3-y1),2));
    double s = (edge1+edge2+edge3)/2;
    double S = sqrt(s*(s-edge1)*(s-edge2)*(s-edge3));

    double ans;
    ans = 2*S/(edge1+edge2+edge3+4*S/edge1);
    ans = max(ans,2*S/(edge1+edge2+edge3+4*S/edge2));
    ans = max(ans,2*S/(edge1+edge2+edge3+4*S/edge3));
    cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
D=[1]*(N+1)
MOD=1000000007
for _ in range(M):
    i = int(input())
    D[i]=0

C = [0]*(N+1)
C[0]=1
for i in range(N-1):
    C[i+1]+=(C[i]*D[i])%MOD
    C[i+2]+=(C[i]*D[i])%MOD
C[N]+=(C[N-1]*D[N-1])%MOD
    #print(C)
print(C[N]%MOD)


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

int main() {
	char s[3];
	int cnt = 0;

	for (int i = 0; i < 3; i++) {
		cin >> s[i];
		if (s[i] == '1') {
			cnt++;
		}
	}
	
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int h1,h2,w1,w2;
	cin >> h1 >> w1 >> h2 >> w2;
	cout << (h1-h2)*(w1-w2) << endl; 
}

Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vl A(N),B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    rep(i,N-2){
        if(A[i]==B[i]&&A[i+1]==B[i+1]&&A[i+2]==B[i+2]){
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3660
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001
#define mod 1000000007
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl>
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
#define google cout << "Case #" << ++it << ": " << ans << endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll it = 0, ans = 0;

ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (auto i=2; i<MAXN; i++)
  		spf[i] = i;
  	for (auto i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (auto i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (auto j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
	return;
}

vl getFactorization(ll x)
{
    vl ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}


void check()
{
	ll n;
	cin >> n;
	vl a(n), b(n);
	for(int i=0;i<n;i++) cin >> a[i] >> b[i];
	for(int i=0;i<n;i++) {
		ll cnt = 0;
		for(int j=i;j<i+3 and j<n;j++) {
			if(a[j]==b[j]) {
				cnt++;
			}
		}
		if(cnt==3) {
			cy;
			return;
		}
	}
	cn;
    return ;
}

int32_t main()
{
    fastio
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}


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

int main(){
  int A, B; cin >> A >> B;
  int coins = 0;
  for(int i = 0; i < 2; i++){
    int max = 0;
    if(A >= B){
      max = A;
      A--;
    }
    else{
      max = B;
      B--;
    }
    coins += max;
  }
  cout << coins;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 2000010;

int x,y;

char nam[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	x=read(),y=read();
	int t=y-x*2;
	if((t%2==0)&&((t/2)<=x)&&(x*2<=y)) printf("Yes\n");
	else printf("No\n"); 
	
	return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
	char c[100][101];
	int h,w,i,j,k;
	
	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++)scanf("%s",&c[i]);
	for(i=0;i<h;i++)printf("%s\n%s\n",c[i],c[i]);
	return 0;
}

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

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)2e5 + 1;
const long long INF = 1e18;

typedef long long ll;
typedef long double ld;

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

int n;
string s;
map < char, int > used;
int main (){
  cin >> n >> s;
  int ans = 0;
  forn (i, 0, s.size() - 1){
    int cur = 0;
    forn (j, 0, i){
      used[s[j]] = 1;
    }
    forn (j, i + 1, s.size() - 1){
      if (used[s[j]]){
        cur++;
        used[s[j]] = 0;
      }
    }
    ans = max(ans, cur);
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;

int main() {

	long n;

	cin >> n;

	vector<long> a(n);

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

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

	for (long i = 0; i < n-1; i++) {
		if (a[i] == a[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1792
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    ans := 0
    a := make([]int, n)
    for i:=0; i<n; i++{
        fmt.Scan(&a[i])
    }
    for i:=0; i<n; i++{
        for j:=0; j<n; j++{
            if i==j{
                continue
            }
            ans = max32(ans,abs32(a[i]-a[j]))
        }
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll p[9600] = { 2 }, cnt = 1, a[100010] = {};
	ll yojo = 1;
	bool f = 0, b[100010] = {}, c[100010] = {};
	b[2] = 1;
	for (int i = 3; i <= 100000; i += 2) {
		for (int j = 0; j < cnt; j++)if (i%p[j] == 0) {
			f = 1;
			break;
		}
		if (f)f = 0;
		else {
			b[i] = 1;
			if (b[i / 2 + 1]) {
				c[i] = 1;
				cnt++;
			}
			p[yojo] = i;
			yojo++;
		}
		a[i] = cnt - 1;
	}
	ll q, l, r, ans;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		ans = a[r] - a[l];
		if (c[l])ans++;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  int a=n%10;
  if(a==3){
    cout<<"bon"<<endl;
    return 0;
  }
  if((a>1&&a<=5)||a==7||a==9){
    cout<<"hon"<<endl;
    return 0;
  }
  cout<<"pon"<<endl;
}

Measured memory_bytes: 3628
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static String[] card;
	static HashSet<String> set;
	static int N;

	static void rec(int[] p, int d) {
		if (d == p.length) {
			String all = "";
			for (int i = 0; i < d; ++i) {
				all += card[p[i]];
			}
			set.add(all);
			return;
		}
		OUT: for (int i = 0; i < N; ++i) {
			for (int j = 0; j < d; ++j) {
				if (p[j] == i) continue OUT;
			}
			p[d] = i;
			rec(p, d + 1);
		}
	}

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			int K = sc.nextInt();
			if (N == 0) break;
			card = new String[N];
			for (int i = 0; i < N; ++i) {
				card[i] = sc.next();
			}
			set = new HashSet<String>();
			int[] p = new int[K];
			rec(p, 0);
			System.out.println(set.size());
		}
	}

}

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

int main() {
    int s, s_1, s_2, s_3;
    int count;
    cin >> s;
    s_1 = s % 10;
    if(s_1 == 1)
        count++;
    
    s_2 = s / 10 % 10;
    if(s_2 == 1)
        count++;

    s_3 = s / 100 % 10;
    if(s_3 == 1)
        count++;

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;


int main(){
    int n,m;
    vector<int> dp,a;
    cin>>n>>m;
    dp.resize(n+1,0);
    a.resize(n+1,0);
    for(int i=0; i<m; i++){
        int k;
        cin>>k;
        a[k]=1;
    }

    dp[0]=1;
    for(int i=1; i<=n; i++){
        if(a[i] == 0){
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= mod;
        }
    }

cout << dp[n] << endl;
return 0;
}

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

int Ask(string s) {
  cout << "? " + s << endl << flush;
  int ld;
  cin >> ld;
  return ld;
}

int len;  // パスワードの文字数

void insert(string& a, string b) {
  int pos = 0;
  for (int i = 0; i < (int)b.size(); ++i) {

    while (true) {
      string s = a.substr(0, pos) + b[i] + a.substr(pos);
      int ld = Ask(s);
      pos++;
      if (ld == len - (int)s.size()) {
        a = s;
        break;
      }
    }
  }
}

signed main() {
  vector<string> ss;

  string chars;
  for (char c = 'a'; c <= 'z'; c++) chars.push_back(c);
  for (char c = 'A'; c <= 'Z'; c++) chars.push_back(c);
  for (char c = '0'; c <= '9'; c++) chars.push_back(c);

  len = 0;
  for (int i = 0; i < (int)chars.size(); ++i) {
    int charCnt = 128 - Ask(string(128, chars[i]));
    ss.emplace_back(charCnt, chars[i]);
    len += charCnt;
  }

  while (ss.size() > 1) {
    sort(ss.begin(), ss.end(), [](const string& l, const string& r) {
      return l.size() < r.size();
      });

    insert(ss[1], ss[0]);
    ss.erase(ss.begin());
  }

  cout << "! " << ss[0] << endl;
  return 0;
}


Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <cstring>
#define MAX_N 1000 + 16
 
using namespace std;
 
int N, H, W;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
int fld[2 * MAX_N][2 * MAX_N], // ??????????????¨?????£??¨??????(i, j)??????????????????????????????
dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };
 
// ????????????????°?????????????????????????????¬¬????§?????????????????????±???????§???????
int compress(int *x1, int *x2, int w)
{
	vector<int>xs;
 
	for (int i = 0; i < N; ++i)
	{
		int tx1 = x1[i], tx2 = x2[i];
		if (1 <= tx1 && tx1 < w) xs.push_back(tx1);
		if (1 <= tx2 && tx2 < w) xs.push_back(tx2);
	}
	xs.push_back(0);
	xs.push_back(w);
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for (int i = 0; i < N; ++i)
	{
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size() - 1;
}
 
int bfs()
{
	int ans = 0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (fld[i][j]) continue;
			++ans;
			queue<pair<int, int> >que;
			que.push(make_pair(j, i));
			while (!que.empty())
			{
				int nx = que.front().first, ny = que.front().second;
				que.pop();
 
				for (int i = 0; i < 4; ++i)
				{
					int tx = nx + dx[i], ty = ny + dy[i];
					if (tx < 0 || W < tx || ty < 0 || H< ty || fld[ty][tx] > 0) continue;
					que.push(make_pair(tx, ty));
					fld[ty][tx] = 1;
				}
			}
		}
	}
	return ans;
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	while (cin >> W >> H, W | H)
	{
		cin >> N;
		for (int i = 0; i < N; ++i)
		{
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		}
 
		memset(fld, 0, sizeof(fld));
 
		W = compress(X1, X2, W);
		H = compress(Y1, Y2, H);
 
		// imos-???
		for (int i = 0; i < N; i++)
		{
			fld[Y1[i]][X1[i]]++;
			fld[Y1[i]][X2[i]]--;
			fld[Y2[i]][X1[i]]--;
			fld[Y2[i]][X2[i]]++;
		}
		// ?¨?????´??§?
		for (int i = 0; i < H; i++)
		{
			for (int j = 1; j < W; j++)
			{
				fld[i][j] += fld[i][j - 1];
			}
		}
		// ???????´??§?
		for (int i = 1; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				fld[i][j] += fld[i - 1][j];
			}
		}// ?´??§??????????fld??????0??¨?????¨????????????
		cout << bfs() << endl;
	}
	return 0;
}
///////////////////////////End Sub//////////////////////////////////

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N;
	int32 res = 0;
	priority_queue<int64> big, sml;
	cin >> N;
	vector<int64> A(N), B(N);
	REP(i, N){ cin >> A[i]; }
	REP(i, N){ cin >> B[i]; }
	REP(i, N){
		if(A[i] > B[i]) big.push(A[i]-B[i]);
		if(A[i] < B[i]) sml.push(B[i]-A[i]);
	}
	int64 rest = 0;
	while(sml.size()){
		while(sml.top() > rest && big.size()){
			rest += big.top();
			big.pop();
			res++;
		}

		if(sml.top() <= rest){
			rest -= sml.top();
			sml.pop();
			res++;
		}else{
			rest = -1;
			break;
		}
	}
	if(rest < 0){
		cout << rest << endl;
	}else{
		cout << res << endl;
	}
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

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

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int Mod = 1e9 + 7;

const int maxn = 110;

int n, step;
int a[maxn + 5];

int dp[maxn + 5][maxn + 5][maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n), step = n, n = (n << 1) - 1;
	REP(i, 0, n) scanf("%d", a + i);
	sort(a, a + n);
	dp[0][1][0] = 1;
	int mid = n >> 1;
	REP(i, 0, step) 
	{
		if (i)
		{
			static int nxt[maxn + 5][maxn + 5];
			if (a[mid + i] != a[mid + i - 1])
			{
				memset(nxt, 0, sizeof nxt);
				REP(j, 1, n + 1) REP(k, 0, j)
					if (dp[i][j][k])
					{
						nxt[j + 1][k] = dp[i][j][k];
					}
				memcpy(dp[i], nxt, sizeof dp[i]);
			}
			if (a[mid - i] != a[mid - i + 1])
			{
				memset(nxt, 0, sizeof nxt);
				REP(j, 1, n + 1) REP(k, 0, j)
					if (dp[i][j][k])
					{
						nxt[j + 1][k + 1] = dp[i][j][k];
					}
				memcpy(dp[i], nxt, sizeof dp[i]);
			}
		}
		REP(j, 1, n + 1) REP(k, 0, j) if (dp[i][j][k]) REP(l, 0, j)
		{
			if (l < k)
			{
				(dp[i + 1][j - (k - l - 1)][l] += dp[i][j][k]) %= Mod;
			}
			else if (l == k)
			{
				(dp[i + 1][j][l] += dp[i][j][k]) %= Mod;
			}
			else if (l > k)
			{
				(dp[i + 1][j - (l - k - 1)][k + 1] += dp[i][j][k]) %= Mod;
			}
		}
	}
	int ans = 0;
	REP(i, 0, n + 1) REP(j, 0, i) (ans += dp[step][i][j]) %= Mod;
	(ans += Mod) %= Mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,m,ans,A[305][305],pw[605];
int guass(int m,int n)
{
	int i=0,j=0,r;
	while(i<m&&j<n)
	{
		r=i;
		for(int k=i;k<m;k++)if(A[k][j]){r=k;break;}
		if(A[r][j])
		{
			if(r!=i)for(int k=0;k<=n;k++)swap(A[r][k],A[i][k]);
			for(int u=i+1;u<m;u++)
			if(A[u][j])for(int k=i;k<=n;k++)A[u][k]^=A[i][k];
			i++;
		}
		j++;
	}
	return i;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	scanf("%d",&A[j][i]);
	pw[0]=1;
	for(int i=1;i<=n+m;i++)pw[i]=2ll*pw[i-1]%mod;
	ans=(pw[n+m-1]-pw[n+m-1-guass(m,n)]+mod)%mod; 
	printf("%d\n",ans);
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

const long MAX = 1000001;

vector<long>	Primes;

void	PrimeInit(vector<long> &P) {
	P.erase(P.begin(), P.end());
	P.push_back(2);
	vector<bool> p(MAX+1, false);
	for (long i=3; i<=MAX; i +=2) {
		if (p.at(i))
			continue;
		P.push_back(i);
		for (int j=i; j<=MAX; j+=i+i)
			p.at(j)=true;
	}
}

void	getPrimes(long A, vector<long> &AP, const vector<long> &P) {
	long i=0;
	long SQ=sqrt(A);
	while(P.at(i)<=SQ) {
		if (0==A%P.at(i)) {
			AP.push_back(P.at(i));
			A /=P.at(i);
		} else
			i++;
		if (1==A)
			break;
	}
	if (1!=A)
		AP.push_back(A);
}

void unique_count(vector<long> &a, vector<vector<long>> &b) {
	b.erase(b.begin(), b.end());
	for (long i=0; i<a.size(); i++)
		if ((i>0)&&(a.at(i)==a.at(i-1)))
			b.back().at(1)++;
		else
			b.push_back({a.at(i), 1});
	return;
}

int	main() {
	// Init
	PrimeInit(Primes);
	// Read
	long N;
	cin >>N;
	vector<long> A(N, 0);
	for (long i=0; i<N; i++)
		cin >>A.at(i);
	// Go
	// Get Primes for each
	vector<vector<long>> APrimes(N);
	for (long i=0; i<N; i++) {
		getPrimes(A.at(i), APrimes.at(i), Primes);
	}
	// Unique Count
	vector<vector<vector<long>>> APrimesM(N);
	for (long i=0; i<N; i++) {
		unique_count(APrimes.at(i), APrimesM.at(i));
	}
	// Get LCM
	vector<vector<long>> LCM0;
	for (long i=0; i<N; i++)
		for (long j=0; j<APrimesM.at(i).size(); j++)
			LCM0.push_back(APrimesM.at(i).at(j));
	sort(LCM0.begin(), LCM0.end());
	// If empty, insert dummy
	if (0==LCM0.size())
		LCM0.push_back({1, 1});
	vector<vector<long>> LCM;
	LCM.push_back(LCM0.at(0));
	for (int i=1; i<LCM0.size(); i++)
		if (LCM.back().at(0)==LCM0.at(i).at(0))
			LCM.back().at(1)=LCM0.at(i).at(1);
		else
			LCM.push_back(LCM0.at(i));
	for (int i=0; i<LCM.size(); i++) {
		long P=LCM.at(i).at(0);
		long M=LCM.at(i).at(1);
		long L=1;
		for (int j=0; j<M; j++)
			L *=P;
		LCM.at(i).push_back(L);
	}
	// Calc Sum of B
	long BB=0;
	for (int i=0; i<N; i++) {
		// Get B for each
		vector<vector<long>> B;
		long ix=0;
		long B0=1;
		for (long j=0; j<LCM.size(); j++) {
			long P=LCM.at(j).at(0);
			long M=LCM.at(j).at(1);
			if ((ix<APrimesM.at(i).size()) && (P==APrimesM.at(i).at(ix).at(0))) {
				long MM=M-APrimesM.at(i).at(ix).at(1);
				long L=1;
				for (int k=0; k<MM; k++)
					L *=P;
				B0 *=L;
				ix++;
			} else {
				B0 *=LCM.at(j).at(2);
			}
			B0 %=MOD;
		}
		BB +=B0;
		BB %=MOD;
	}
	cout <<BB <<endl;
	return 0;
}



Measured memory_bytes: 8560
import java.util.*;//ABC121_A
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();

    int A = H*W;
    int B = (h*W)+(w*H)-(h*w);
    System.out.println(A-B);
  }
}


Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(void){
	set<int> s;

	int n;

	cin >> n;

	int d;

	for (int i = 0; i < n; i++){
		cin >> d;
		s.insert(d);
	}


	cout << s.size() << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    AServalVsMonster solver = new AServalVsMonster();
    solver.solve(1, in, out);
    out.close();
  }

  static class AServalVsMonster {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int h = in.nextInt();
      int a = in.nextInt();
      out.println(MathLib.divRoundUp(h, a));
    }

  }

  static class MathLib {

    public static long divRoundUp(long a, long b) {
      return (a + b - 1) / b;
    }

  }
}



Measured memory_bytes: 25300
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n,d[200005],m,t[200005],co=0,l;
	cin>>n;
	for(int i=0;i<n;i++)cin>>d[i];
	sort(d,d+n);
	cin>>m;
	for(int j=0;j<m;j++)cin>>t[j];
	sort(t,t+m);
	l=0;
	for(int i=0;i<n;i++){
		if(d[i]==t[l]){
			l++;
			co++;
		}
	}
		
	if(co>=m)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	//for(int i=0;i<n;i++)cout<<d[i];
	//for(int j=0;j<m;j++)cout<<t[j];
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
  int n,x;
  int a[101];
  int i,j;
  int t;
  int sum=0;
  scanf("%d%d",&n,&x);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      t=a[i];
      if(a[i]>a[j]){
        a[i]=a[j];
        a[j]=t;
      }
    }
  }
  j=0;
  for(i=0;i<n;i++){
    sum+=a[i];
    if(sum>x){
      break;
    }
    j++;
  }
  if(sum<x && j>0) j--;
  printf("%d",j);
  return 0;
}


Measured memory_bytes: 1692
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	int l,r;
	cin>>l>>r;
	int d;
	cin>>d;
	int res=0;
	rb(i,l,r){
		if(i%d==0){
			res++;
		}
	}cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
    int n = 0;
    str S;
    cin >> S;
    int plus = count(all(S), '+');
    int minus = count(all(S), '-');
    print(n + plus - minus);
  return 0;
}




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

int main()
{
    ll n, count = 0;
    ll count_max = 0;
    cin >> n;
    vector<ll> h(n);

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

    for (ll i = 0; i < n - 1; i++)
    {
        if (h[i] >= h[i + 1])
        {
            count++;
            count_max = max(count_max, count);
        }
        else
        {
            count = 0;
        }
    }

    cout << count_max << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<cstdlib>
using namespace std ;

#define MAXM 1007
#define MAXN 5007

int n , m ;
int cost[ MAXM ] ;
int mask[ MAXM ] ;


int dp[ MAXN ] ;
int nw[ MAXN ] ;

void input ( ) {
    scanf ( "%d%d" , &n , &m ) ;
    for ( int i = 1 ; i <= m ; ++ i ) {
        int len ;
        scanf ( "%d%d" , &cost[ i ] , &len ) ;
        for ( int j = 0 ; j < len ; ++ j ) {
            int x ;
            scanf ( "%d" , &x ) ;
            mask[ i ] += (1<<(x-1)) ;
        }
    }
}

void solve ( ) {
    for ( int i = 0 ; i < (1<<n) ; ++ i ) {
        dp[ i ] = nw[ i ] = -1 ;
    }
    dp[ 0 ] = 0 ;
    for ( int i = 1 ; i <= m ; ++ i ) {
        for ( int j = 0 ; j < (1<<n) ; ++ j ) {
            if ( dp[ j ] == -1 ) { continue ; }
            int aux = dp[ j ] + cost[ i ] ;
            if ( dp[ j | mask[ i ] ] == -1 || dp[ j | mask[ i ] ] > aux ) {
                dp[ j | mask[ i ] ] = aux ;
            }
        }
    }
    printf ( "%d\n" , dp[ (1<<n) - 1 ] ) ;
}

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


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a.sort()
a_dic = {}
for i in range(N):
    n = a[i]
    a_dic.setdefault(n, 0)
    a_dic[n] += 1
maximum = 0
for j in a_dic:
    tmp = a_dic[j] + a_dic.get(j-1,0) + a_dic.get(j+1,0)
    if tmp > maximum:
        maximum = tmp
print(maximum)

Measured memory_bytes: 14180
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int A[SIZE], B[SIZE], C[SIZE];
map<int, int> mm[SIZE];

ll ans[SIZE], in[SIZE];

int main(){
  int N, M, T;
  set<int> ss;

  cin >> N >> M >> T;

  for(int i=0; i<M; i++) {
    cin >> A[i] >> B[i] >> C[i];
    B[i]--;
  }

  for(int i=0; i<M; i++) {
    if (C[i] == 0) {
      auto it = ss.find(B[i]);
      ss.erase(it);

      for(int p : ss) {
        int a = p, b = B[i];
        int add = A[i] - max(in[a], in[b]);
        if (a > b) swap(a, b);
        mm[a][b] += add;
      }

      in[B[i]] = 0;

    } else {

      ss.insert(B[i]);
      in[B[i]] = A[i];
    }
  }

  for(int p : ss) {
    for(int q : ss) {
      if (p < q) {
        int add = T - max(in[p], in[q]);
        mm[p][q] += add;
      }
    }
  }

  const ll e8 = 100000000LL;

  for(int i=0; i<N; i++) {
    ans[i] = 0 * e8 + N - (i == 0);
  }

  for(int i=0; i<N; i++) {
    for(auto p : mm[i]) {
      int a = i;
      int b = p.first;
      int v = p.second;

      ans[a] = max(ans[a], v * e8 + N - b);
      ans[b] = max(ans[b], v * e8 + N - a);
    }
  }

  for(int i=0; i<N; i++) {
    int p = N - ans[i] % e8 + 1;

    printf("%d\n", p);
  }


  return 0;
}



Measured memory_bytes: 187692
//参考：https://atcoder.jp/contests/abc054/submissions/7054929
//参考Ｐｙｈｏｎ：https://atcoder.jp/contests/abc054/submissions/3734361
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;

class Program{
  static List<int>[] v;
  static bool[] visited;
  static int n, ans;
  
  static void dfs(int node, int depth){
    if(depth == n){
      ans++;
      //Write("depth = {0}, node = {1}", depth, node);
      //WriteLine("おでん");
      return;//void型の関数でreturnは途中で戻るの意
    }
    
    visited[node] = true;
    //Console.WriteLine("[{0}]", int.Join(", ", v));
    
    foreach(int next in v[node]){//当てはまる辺をすべて調査
      //WriteLine("次は{0}", next);
      if( !visited[next] ){//falseなら入る
        dfs(next, depth+1);
      }
    }
    
    //WriteLine("End Time");
    visited[node] = false;//初期化
    return;
  }
  
  static void Main(string[] args){
    int m;
    string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
    n = int.Parse(str[0]);
    m = int.Parse(str[1]);
    //Console.WriteLine("n = {0} m = {1}", n, m);//改行付き出力
    
    v = new List<int>[n+1];
    for(int i = 1 ; i <= n ; i++){
      v[i] = new List<int>();
    }
    
    int[] a = new int[m];
    int[] b = new int[m];
    for(int i = 0 ; i < m ; i++){
      str = Console.ReadLine().Split(' ');
      a[i] = int.Parse(str[0]);
      b[i] = int.Parse(str[1]);
      
      v[a[i]].Add(b[i]);
      v[b[i]].Add(a[i]);
    }
    
    ans = 0;
    //入力完了
    
    visited = new bool[n+1];//初期値は全部"false"
    dfs(1, 1);//1個目のノード、深さ1→深さnなら全探索完了してる
    WriteLine(ans);
        
  }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  ll ab = a*b;
  c -= a; c-= b;
  long double cd = static_cast<long double>(c) / 2;
  long double abd = sqrt(static_cast<long double>(ab));
  bool ans = abd < cd;
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,a[2][18],f[18][262144],cnt[18][262144],sz[262144],ans=1e9;
int main(){
	n=read();
	FOR(i,0,n-1) a[0][i]=read();
	FOR(i,0,n-1) a[1][i]=read();
	FOR(i,0,(1<<n)-1) sz[i]=sz[i>>1]+(i&1);
	FOR(i,0,n-1) FOR(j,0,(1<<n)-1) FOR(k,0,n-1) if(((j>>k)&1) && i>k) cnt[i][j]++;
	MEM(f,0x3f);
	FOR(i,0,n-1) f[i][1<<i]=cnt[i][(1<<n)-1];
	FOR(j,1,(1<<n)-1) FOR(i,0,n-1) if((j>>i)&1){
		FOR(k,0,n-1) if(!((j>>k)&1) && a[abs(i-(sz[j]-1))%2][i]<=a[abs(k-sz[j])%2][k]){
			f[k][j|(1<<k)]=min(f[k][j|(1<<k)],f[i][j]+cnt[k][((1<<n)-1)^j]);
		}
	}
	FOR(i,0,n-1) ans=min(ans,f[i][(1<<n)-1]);
	printf("%d\n",ans==1e9?-1:ans);
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int n,m;
vector<int> h, adj_val;
vector<vector<int>> g;


int main()
{
	cin>>n>>m;
	g.resize(n);
	h.resize(n);
	adj_val.resize(n,0);
	rep(i,n)cin>>h[i];
	rep(i,m){
		int a,b;
		cin>>a>>b;
		g[a-1].push_back(b-1);
		g[b-1].push_back(a-1);

		adj_val[a-1] = max(adj_val[a-1],h[b-1]);
		adj_val[b-1] = max(adj_val[b-1],h[a-1]);
	}
	int ans=0;
	rep(i,n){
		if(adj_val[i]<h[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9008
#include <iostream>

using namespace std;

int main()
{
	long a, b ;
	cin >> a ;
	cin >> b ;
	
	if( a * b <= 0 )
	{
		cout << "Zero" << endl ;
	}
	else
	{
		if( a + b <= 0 )
		{
			if( ( b - a ) % 2 == 0 )
			{
				cout << "Negative" << endl ;
			}
			else
			{
				cout << "Positive" << endl ;
			}
		}
		else
		{
			cout << "Positive" << endl ;
		}
	}
	
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

class Union_Find{
private:
    vector<int> par, rank;
public:
    Union_Find(int Max_Node){
        par.resize(Max_Node);
        rank.resize(Max_Node);
        for(int i = 0; i < Max_Node; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

  
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
  
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return ;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y){
        return (find(x) == find(y));
    }
};


int main(){
  int N, K, L, a, b;
  cin >> N >> K >> L;
  Union_Find train(N + 1), road(N + 1);
  
  for(int i = 0; i < K; i++){
    cin >> a >> b;
    road.unite(a, b);
   }
  
  for(int i = 0; i < L; i++){
    cin >> a >> b;
    train.unite(a, b);
  }
  vector<pair<int,int>> vp;
  map<pair<int, int>, int> m;
  for(int i = 1; i <= N; i++){
    pair<int,int> pi = mp(road.find(i), train.find(i));
    vp.pb(pi);
    m[pi]++;
  }

  for(int i = 0; i < N; i++){
    if(i != 0)cout << " ";
    cout << m[vp[i]];
  }
  cout << endl;
  
  return 0;
}


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

using namespace std;

int main() {
	int m;
	int n;
	cin >> m;
	cin >> n;
	int a[10];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int k = m; k < 1000000; k++) {
		bool f = true;
		for (int j = 0; j < 5; j++) {
			int t = pow(10, 4 - j);
			if (k <t) {
				continue;
			}
			t = (k / t) % 10;
			for (int r = 0; r < n; r++) {
				if (a[r] == t)f = false;
			}
		}
		if (f){
			cout << k;
			return 0;
		}
	}
}

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

int main(){

    long long sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string s;
    for(int i = 0; i < ty-sy; i++ ){
        s.push_back('U');
    }
    for(int i = 0; i < tx-sx; i++ ){
        s.push_back('R');
    }
    for(int i = 0; i < ty-sy; i++ ){
        s.push_back('D');
    }
    for(int i = 0; i < tx-sx; i++ ){
        s.push_back('L');
    }

    s.push_back('L');
    for(int i = 0; i < ty-sy + 1; i++ ){
        s.push_back('U');
    }
    for(int i = 0; i < tx-sx + 1; i++ ){
        s.push_back('R');
    }
    s.push_back('D');
    s.push_back('R');
    for(int i = 0; i < ty-sy+1; i++ ){
        s.push_back('D');
    }
    for(int i = 0; i < tx-sx+1; i++ ){
        s.push_back('L');
    }
    s.push_back('U');

    cout << s << endl;


}

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

using namespace std;

string s;
int t , nr1 , nr2 , nr3 , nr4;

int main()
{
    cin >> t;
    while(t --)
    {
        cin >> s;
        if(s == "AC")
            nr1 ++;
        if(s == "WA")
            nr2 ++;
        if(s == "TLE")
            nr3 ++;
        if(s == "RE")
            nr4 ++;
    }
    cout << "AC x " << nr1 << '\n';
    cout << "WA x " << nr2 << '\n';
    cout << "TLE x " << nr3 << '\n';
    cout << "RE x " << nr4 << '\n';
    return 0;
}


Measured memory_bytes: 3620