akhauriyash/Code-Regression huggingface dataset:
n, m = [ int(v) for v in input().split() ]
image = [ input() for i in range(n)]
temp_image = [ input() for i in range(m)]


ans = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        part_image = [ image[k][j:j+m] for k in range(i,i+m) ]
        if part_image == temp_image:
            ans = "Yes"
print(ans)

Measured memory_bytes: 39152
def sixnumber(aaa)
    
    aaa = aaa.to_s
    ll = aaa.length
    
    (6-ll).times{
        
        aaa = "0"+aaa
    }
    
    return aaa
    
end


n,m = gets.split.map(&:to_i)

arr = []

ansarray = Array.new(m,0)

i = 0
m.times{
    
    aa = gets.split.map(&:to_i)
    
    aa+=[i]
    i+=1
    arr<<aa}


arr = arr.sort



i = 0
count = 1
m.times{
    
    if i>0 && arr[i][0] == arr[i-1][0]
        
        count+=1
        
    else 
        count = 1
    end
    pre = arr[i][0]
    id = arr[i][2]
    
    ansarray[id] = sixnumber(pre)+sixnumber(count)
    
    
    i+=1
}


i = 0
m.times{
    
    puts ansarray[i]
    i+=1
}








Measured memory_bytes: 18180
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
const int NN = 1e6+10;
typedef long long ll;

int n;
int main(){
    cin>>n;
    ll coun = 0;
    for(int i = 1,odd = 1;i<=n;i++){
        if(std::to_string(i).length() %2 == 1) coun++;
    }
    cout<<coun<<endl;
    return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int A, B, C, D, E, k;

int main() {
    cin >> A >> B >> C >> D >> E;
    cin >> k;

    int max_p = max(max(max(A, B), max(C, D)), E);
    int min_p = min(min(min(A, B), min(C, D)), E);
    string result = ((max_p - min_p) > k) ? ":(" : "Yay!";
    cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    string S[a];
    REP(i,a){
        string s;
        cin>>s;
        S[i]=s;;
    }
    REP(i,b+2) cout<<'#';
    cout<<endl;
    REP(i,a) cout<<'#'<<S[i]<<'#'<<endl;
    REP(i,b+2) cout<<'#';
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> 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().expect("failed to parse token")
}

fn main() {
    let N: u128 = read();

    let mut ans = 0;

    for i in 1..N+1 {
        if i % 3 != 0 && i % 5 !=0 {
            ans += i;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2164
package main

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



func main() {
    var n,T int
    fmt.Scan(&n,&T)
    inf := 1000000000
    ans := inf
    for i:=0; i<n; i++{
        var c,t int
        fmt.Scan(&c,&t)
        if t <= T{
            ans = min32(ans,c)
        }
    }
    if ans == inf{
        fmt.Println("TLE")
    } else {
        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
h,w = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[y][x]=="#":
            if x-1>=0 and s[y][x-1]=="#":
                continue
            elif y-1>=0 and s[y-1][x]=="#":
                continue
            elif x+1<w and s[y][x+1]=="#":
                continue
            elif y+1<h and s[y+1][x]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int n;
    int flag = 0;
    cin>>n;
    for(int i=1;i<n;i++){
        if(n%i==0){
            if(i<=9 and n/i<=9)flag=1;
        }
    }
    if(flag==1 or n==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, m,i,a[10001],sum = 0;
	
	scanf("%d %d", &n, &m);
	for (i = 1; i <= m; i++)
	{
		scanf("%d", &a[i]);
		sum += a[i];
	}
	if (n - sum >= 0)
	{
		printf("%d\n", n - sum);
		
	}
	else
	{
		printf("-1");

	}
	return 0;
}

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

int main() {
    int n;
    while (cin >> n && n) {
        double sum = 0, sum2 = 0;
        for (int i = 0; i < n; i++) {
            int s; cin >> s;
            sum += s;
            sum2 += s * s;
        }
        double ave = sum / n;
        cout << fixed << setprecision(6);
        cout << sqrt(sum2 / n - ave * ave) << endl;
    }
    return 0;
}


Measured memory_bytes: 3260
#include <iostream>

int main(){
  int A,B,C;

  std::cin >> A >> B >> C;

  if(A == B && A != C && B != C ||
     A == C && A != B && B != C ||
     B == C && A != B && A != C)
    std::cout <<"Yes"<<std::endl;
  else
    std::cout << "No"<<std::endl;

  return 0;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

bool isPrime(int n){
  for(int i = 2; i*i<=n; i++){
    if(n%i == 0) return false;
  }
  return true;
}

int main(){
  int n;
  while(cin>>n,n){
    int ans = 0;
    FOR(i,n+1,2*n+1){
      if(isPrime(i))ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 868
import java.util.Scanner;

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

        char[] s = sc.next().toCharArray();

        boolean ans = true;
        for (int i = 1; i < 4; i++) {
            if (s[i-1] == s[i]) {
                ans = false;
                break;
            }
        }

        System.out.println(ans ? "Good" : "Bad");
    }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <vector>
#define INT_MAX 100000000
#define N_MAX 10001

using namespace std;

class road {
public:
  int to,dist,cost;
  road(int to,int dist,int cost) : to(to),dist(dist),cost(cost) {}
};

int n,m;
int before[N_MAX],ans;
vector<road> roads[N_MAX];

int main(){
  while(scanf("%d %d",&n,&m),n){
    int i,j;

    ans = 0;
    for(i=0; i<N_MAX; i++) {
      roads[i].clear();
      before[i] = 0;
    }

    for(i=0; i<m; i++){
      int u,v,d,c;
      scanf("%d %d %d %d",&u,&v,&d,&c);
      roads[u].push_back(road(v,d,c));
      roads[v].push_back(road(u,d,c));
    }

    bool visited[n+1];
    int d[n+1];
    for(i=1; i<=n; i++){
      d[i] = INT_MAX;
      visited[i] = false;
    }

    d[1] = 0;

    for(;;){
      int u;
      int mincost = INT_MAX;
      for(i=1; i<=n; i++)
	if(!visited[i] && d[i]<mincost){
	  mincost = d[i]; u = i;
	}

      if(mincost == INT_MAX) break;

      visited[u] = true;
      for(i=0; i<roads[u].size(); i++)
	if(roads[u][i].to==before[u])
	  ans += roads[u][i].cost;

      for(i=0; i<roads[u].size(); i++){
	int v = roads[u][i].to, dist = roads[u][i].dist, cost = roads[u][i].cost;

	if(visited[v]) continue;

	int cost1;
	for(j=0; j<roads[v].size(); j++)
	  if(roads[v][j].to==before[v])
	    cost1 = roads[v][j].cost;

	if(d[v]>d[u]+dist || (d[v]==d[u]+dist && cost1 > cost)){
	  d[v] = d[u]+dist;
	  before[v] = u;
	}
      }
    }

    printf("%d\n",ans);
  }
  return 0;
}

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

int main()
{
  int vac, assign, sum;
  sum = 0;

  cin >> vac >> assign;
  int day[assign];


  for(int i=0; i<assign ; i++)
  {
    cin >> day[i];
    sum += day[i];
  }

  if(sum > vac)
  {
    cout << "-1" << endl;
  }
  else if(sum == vac)
  {
    cout << "0" << endl;
  }
  else
  {
    cout << vac - sum << endl;
  }

}


Measured memory_bytes: 3664
#include<stdio.h>

int main(){
  int n;
  scanf("%d\n", &n);
  int a[n], i, k;
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  for(i = 1; i < n; i++){
    
    for(k = 0; k < n - 1; k++)
      printf("%d ", a[k]);
    printf("%d\n", a[n-1]);
    
    int v = a[i];
    int j = i - 1;
    while( j >= 0 && a[j] > v){
      a[j + 1] = a[j];
      j--;
    }
    a[j+1] = v;
  }

  for(k = 0; k < n - 1; k++)
      printf("%d ", a[k]);
    printf("%d\n", a[n-1]);
  
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7, maxn = 1000001;
const double PI = acos(-1);
int dp[110][11][3], k, n;
string num;

int solve(int pos, int nz, bool less){
    int& tmp = dp[pos][nz][less];
    if (pos == n) return nz == k;
    if (nz > k) return 0;
    if (tmp != -1) return tmp;

    tmp = 0;
    int dig = num[pos] - '0';
    if (less){

        for (int i=0; i<10; i++){
            tmp += solve(pos+1, nz + (i > 0), true);
        }
    }

    else {
        for (int i=0; i<dig; i++){
            tmp += solve(pos+1, nz + (i > 0), true);
        }
        tmp += solve(pos + 1, nz + (dig > 0), false);
    }
    return tmp;
}

int main (){
    ios_base::sync_with_stdio(false);
    memset(dp, -1, sizeof dp);
    cin >> num >> k;
    n = num.size();

    cout << solve(0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(180*(n-2))
    return

#B
def B():
    s = S()
    res = 15-len(s)
    k = s.count("o")
    if k+res >= 8:
        print("YES")
    else:
        print("NO")
    return

#C
def C():
    n,a,b,c = LI()
    return

#D
def D():
    n = I()
    v = [[] for i in range(n)]
    f = [[0,i] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
        f[a][0] += 1
        f[b][0] += 1
    f.sort(key = lambda x:-x[0])
    s = f[0][1]
    c = LI()
    c.sort(key = lambda x:-x)
    f[0][0] = c[0]
    q = deque()
    q.append(s)
    bfs = [1 for i in range(n)]
    f.sort(key = lambda x:x[1])
    bfs[s] = 0
    k = 1
    while q:
        x = q.popleft()
        for y in v[x]:
            if bfs[y]:
                bfs[y] = 0
                f[y][0] = c[k]
                k += 1
                q.append(y)
    ans = 0
    q.append(s)
    bfs = [1 for i in range(n)]
    bfs[s] = 0
    while q:
        x = q.popleft()
        for y in v[x]:
            ans += min(f[x][0],f[y][0])
            if bfs[y]:
                bfs[y] = 0
                q.append(y)
    print(ans//2)
    for i, j in f[:-1]:
        print(i,end = " ")
    print(f[-1][0])
    return

#E
def E():
    n = I()
    return

#F
def F():
    n = I()
    return

#Solve
if __name__ == "__main__":
    D()


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

int main() {
    ll N, K;
    cin >> N >> K;
    
    ll ans = min(N % K, K - N % K);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    if(s[0] == t[2] and s[2] == t[0] and s[1] == t[1]) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main()
{
	ll n,a,b;
	cin >> n >> a >> b;
	ll mn = a*(n-1)+b;
	ll mx = b*(n-1)+a;
	cout << max(0LL,mx-mn+1)<<endl;
}


Measured memory_bytes: 3596
from collections import deque
N,M = map(int,input().split())

graph = [[] for _ in range(N)]
flag = [0] * N

for i in range(M):
  A, B = map(int,input().split())
  A -= 1
  B -= 1
  graph[A].append(B)
  graph[B].append(A)
  
D = deque()
D.append(0)
visited = [False] * N
visited[0] = True

while D:
  v = D.popleft()
  for nv in graph[v]:
    if visited[nv] == True:
      continue
    visited[nv] = True
    flag[nv] = v
    D.append(nv)
    
print("Yes")
for i in range(1,N):
  print(flag[i] + 1)

Measured memory_bytes: 34868
<?php

fscanf(STDIN, "%s %s", $strA, $strB);
fscanf(STDIN, "%d %d", $cnt1, $cnt2);
fscanf(STDIN, "%s", $sctStr);

If($sctStr == $strA) {
  	$cnt1 = $cnt1 - 1;
} Else If ($sctStr == $strB) {
 	$cnt2 = $cnt2 - 1;
}

echo $cnt1." ".$cnt2;

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define fl(n)             for(long long int i=0;i<n;i++)
#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define vi                vector <int>
#define vvi               vector < vi >
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int> 
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define M                 1000000007LL

bool setwise=0;

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


const int MAX = 1000000;
int B[MAX + 1]{};
 




int solve()
{
	int n;
	cin>>n;
	ll a[n],tot=1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		B[a[i]]++;
		tot*=a[i];
	}

	
	ll lcm=a[0],g=a[0];
	for(int i=1;i<n;i++)
	{
		g=gcd(g,a[i]);
		lcm=(a[i]*lcm)/gcd(lcm,a[i]);
	}
	bool flag1 = true;
    bool flag2 = true;
    for (int i = 2; i <= MAX; i++) {
        int cnt = 0;
        for (int j = 1; j < MAX; j++) {
            if (i * j > MAX) break;
            cnt += B[i * j];
        }
        if (cnt > 1) {
            flag1 = false;
        }
        if (cnt == n) {
            flag2 = false;
        }
    }
    if (flag1) {
        cout << "pairwise coprime\n";
    } 
	else if(g==1)
		cout<<"setwise coprime";
	else
	cout<<"not coprime\n";



  return 0;
}


int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
  
  int t=1;
  //cin>>t;
  while(t--)
  {
    solve();
  }
  return 0;
}

 


Measured memory_bytes: 15264
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<ll>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl;
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod2 998244353
#define INT_MAX1 900000000
//////////////////////////////////////////////////////////////////////////////////////////////

int n,k;
int dp[100001];
bool v[100001];
int h[100001];

int s1(int i)
{
    if(i==n-1)
        return 0;
    if(v[i])
        return dp[i];
    v[i] = 1;
    dp[i] = INT_MAX;
    rep(j,i+1,min(n-1,i+k))
    {
        dp[i] = min(dp[i],abs(h[i]-h[j])+s1(j));
    }
    return dp[i];
    
}

void solve()
{
    cin >> n >> k;
    inp(h,n);
    cout << s1(0) << endl;
}
 
int32_t main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

void solve(int &n, int &w, int &h) {
  vector<pair<int, int>> v;
  v.push_back({h, w});
  rep(count, 0, n) {
    int id, s; cin >> id >> s; id--;
    int hlen = v[id].fi;
    int wlen = v[id].se;
    s %= hlen + wlen;
    v.erase(v.begin() + id);
    pair<int, int> one, two;
    if (s < wlen) {
      one = make_pair(hlen, s);
      two = make_pair(hlen, wlen - s);
    } else {
      s -= wlen;
      one = make_pair(s, wlen);
      two = make_pair(hlen - s, wlen);
    }
    if (one.fi * one.se >= two.fi * two.se) {
      v.push_back(two); v.push_back(one);
    } else {
      v.push_back(one); v.push_back(two);
    }
  }
  sort(v.begin(), v.end(),
      [](pair<int, int> &a, pair<int, int> &b){return a.fi * a.se <= b.fi * b.se;}
      );
  rep(i, 0, (int)v.size()) {
    cout << v[i].fi * v[i].se;
    if (i == (int)v.size() - 1) cout << endl;
    else cout << " ";
  }
}

int main() {
  int n, w, h;
  while (cin >> n >> w >> h) 
    if (n != 0 || w != 0 || h != 0) solve(n, w, h);
}



Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi p(N);
    cin >> p;
    int mn = p[0];
    for (int i = 0; i < N; i++) {
        if (mn >= p[i]) {
            ans++;
        }
        mn = min(mn, p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    string d[4] = {"dream", "erase", "eraser", "dreamer"};
    string s;
    cin >> s;
    int len = s.size();

    while(len != 0){
        for(int i=0;i<4;i++){
            string tmp = "";
            if(len < d[i].size()){
                continue;
            }
            tmp = s.substr(len - d[i].size(),d[i].size());
            if (tmp.compare(d[i])==0){
                //s = s.substr(0,len-d[i].size());
                len = len - d[i].size();
                goto loop;
            }
        }
        printf("NO\n");
        return 0;
        loop:;
    }
    printf("YES\n");
}


Measured memory_bytes: 512
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

int main(){
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	int per=min(2*c,a+b);
	int mi=min(x,y),mx=x+y-mi;
	int p=a;if(y==mx)p=b;
	printf("%lld\n",mi*per+min((mx-mi)*2*c,(mx-mi)*p));

	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto a=scanElem;
  auto o=scanString;
  auto b=scanElem;
  if(o=="+")end(a+b);end(a-b);
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    for(int i=0 ; i<n ; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int ans=0;
    for(int j=0 ; j<k ; j++){
        ans+=vec.at(n-j-1);
    }
    cout << ans << endl;
    return 0;
}

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

int ordena(const void *a, const void *b){
  return (*(int *)a)- (*(int *)b);
}

int main (){               //pairwise distinct significa que todos os elementos são únicos.
  int n,b;
  int a[212345];

  scanf("%d", &n);

  for(int i=0; i<n; i++)
    scanf("%d", &a[i]);

  qsort(a,n,sizeof(int), ordena);

  for(int i=0; i<n; i++){
    if (a[i]==a[i+1]){
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");

  return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<string> field(h);
    rep(i,h) cin >> field[i];
    int ans = 0;
    rep(i,1<<h)rep(j,1<<w) {
        int ct = 0;
        rep(k,h)rep(l,w) {
            if (i>>k&1 || j>>l&1) continue;
            if (field[k][l] == '#') ct++;
        }
        if (ct == k) ans++;
    }
    cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        double ex[] = new double[t + 1];
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            double rsum = 0;
            int v[] = new int[m];
            double r[] = new double[m];
            for (int j = 0; j < m; j++) {
                v[j] = sc.nextInt();
                r[j] = sc.nextDouble();
                rsum += r[j];
            }
            ex[i] = 0;
            for (int j = 0; j < m; j++) {
                ex[i] += 1.0 * v[j] * r[j] / rsum;
            }
        }
        int p = sc.nextInt();
        int q = sc.nextInt();
        int v[] = new int[q];
        double r[] = new double[q];
        double rsum = 0;
        for (int j = 0; j < q; j++) {
            v[j] = sc.nextInt();
            r[j] = sc.nextDouble();
            rsum += r[j];
        }
        ex[t] = 0;
        for (int j = 0; j < q; j++) {
            ex[t] += 1.0 * v[j] * r[j] / rsum;
        }
        boolean flag = false;
        for (int i = 0; i < t; i++) {
            if (ex[i] - ex[t] > 0.0000001) {
                flag = true;
                break;
            }
        }
        System.out.println(flag ? "YES" : "NO");

    }
}

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



int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	int x;
	cin >> x;
	if (x < 1200)
	{
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}





	return 0;
}

Measured memory_bytes: 3600
c = input()
alp = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
count1 = 0
count2 = 0
while count2 <= 26:
  if alp[count1] == c:
     count1 += 1
     count2 += 27
  else:
    count1 += 1
    count2 += 1
print(alp[count1])

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

int debug = 0;

int main(){
    ll n,m;
    cin >> n >>m;
    vector<ll> h(n+1);
    vector<vector<ll>> path(n+1);

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

    rep(i,m){
        ll a,b;
        cin >> a>>b;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    if(debug){
        cout << "height:" ;
        for(int i=1;i<n+1;++i) cout <<h[i]<<",";
        cout << endl;
        cout << "link:" << endl;
        for(int i=1;i<n+1;++i){
            for(auto x:path[i]) cout << x << ","; 
            cout << endl;
        }
    }

    int ans = 0;
    for(int i=1;i<n+1;++i){
        ll self=h[i];
        bool good=true;
        for(auto x:path[i]){
            if(debug) cout << "chk:" << h[x] <<","<<self<<":";
            if(h[x]>=self) good=false;
        }
        if(debug) cout <<"point:"<<self<< " "<< good <<endl;
        if(good)ans++;
    }

    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 9868
#include<stdio.h>

int main () {
	int a, b;
	char op;
	
	while ( 1 ) {
		scanf ( "%d %c %d", &a, &op, &b );
		
		if ( op == '+' ) {
			printf( "%d\n", a + b );
		}else if ( op == '-' ) {
			printf( "%d\n", a - b );
		}else if ( op == '*' ) {
			printf( "%d\n", a * b );
		}else if ( op == '/' ) {
			printf( "%d\n", a / b );
		}else {
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
main()
{
	int n,i,s=100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		s=s*1.05;
		if(s%1000!=0){
			s=(s/1000+1)*1000;
		}
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    ll q;
    cin >> q;
    deque<char> dq;
    rep(i, len(s)) dq.push_back(s[i]);
    bool rev = false;
    rep(i, q) {
        ll t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        }
        else {
            ll f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (!rev) dq.push_front(c);
                else dq.push_back(c);
            }
            else {
                if (rev) dq.push_front(c);
                else dq.push_back(c);
            }
        }
    }
    string ans = "";
    for(auto x : dq) ans += x;
    if (rev) reverse(all(ans));
    cout << ans << endl;
    return 0;
}


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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Cost {
    ll cost;
    char direction;
};

std::istream &operator>>(std::istream &in, Cost &o) {
    cin >> o.cost;
    return in;
}


// http://ncastar.hatenablog.com/entry/2016/10/12/224425
int main() {
    ll w, h;
    cin >> w >> h;

    vector<Cost> costs_w(w), costs_h(h);
    rep(i, w) cin >> costs_w[i], costs_w[i].direction = 'v';
    rep(i, h) cin >> costs_h[i], costs_h[i].direction = 'h';

    vector<Cost> costs(w + h);
    rep(i, w) costs[i] = costs_w[i];
    rep(i, h) costs[i + w] = costs_h[i];

    sort(costs.begin(), costs.end(), [&](Cost &c1, Cost &c2) { return c1.cost < c2.cost; });

    ll ans = 0;

    ll used_h = 0, used_w = 0;
    for (Cost cost : costs) {
        if (cost.direction == 'v') {
            ll r = (h + 1) - used_h;
            ll now = r * cost.cost;
            ans += now;
            used_w++;
        } else {
            ll r = (w + 1) - used_w;
            ll now = r * cost.cost;
            ans += now;
            used_h++;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 6528
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))

b = [0] * (n + 1)
b[0] = 1
if 1 not in a:
    b[1] = 1
for i in range(2, n + 1):
    if i in a:
        b[i] = 0
    else:
        b[i] = b[i - 1] + b[i - 2]
print(b[n] % 1000000007)

Measured memory_bytes: 470392
#include <bits/stdc++.h>
#define MOD 998244353
#define MAXN 307
using namespace std;
long long dp[MAXN][MAXN][MAXN];
int main()
{
	string s; int kt;
	cin>>s>>kt;
	int n=s.size();
	vector<int> nl,sz; nl.push_back(-1); sz.push_back(-1);
	for(int i=0;i<n;i++) if(s[i]=='0') nl.push_back(i);
	nl.push_back(n);
	for(int i=nl.size()-1;i>0;i--) sz.push_back(nl[i]-nl[i-1]-1);
	dp[0][0][0]=1;
	for(int i=1;i<sz.size();i++)
	{
		for(int j=0;j<MAXN;j++) for(int k=0;k<MAXN;k++) for(int t=0;t<=sz[i];t++) if(t<=j && t<=k) dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-t][k-t]);
		for(int j=0;j<MAXN;j++) 
		{
			long long sum=0;
			for(int k=MAXN-1;k>=0;k--)
			{
				dp[i][j][k]=(dp[i][j][k]+sum)%MOD;
				sum=(sum+dp[i-1][j][k])%MOD;
			}
		}
	}
	long long res=0;
	for(int i=0;i<min(MAXN,kt+1);i++) res=(res+dp[sz.size()-1][i][0])%MOD;
	cout<<res;
}

Measured memory_bytes: 224412
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
    if (a % 2 == 0) {
      cout << -1 << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    int res = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
      if (a == b && b == c) {
        res = -1;
        break;
      }
      int da = a / 2, db = b / 2, dc = c / 2;
      a = dc + db;
      b = dc + da;
      c = da + db;
      res++;
    }
    cout << res << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class DGatheringChildren {
public:
    vector<int> calc(string s, char now){
        int cnt_odd = 0;
        int cnt_even = 0;
        vector<int> ans(s.size(), 0);
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == now) {
                if (i % 2 == 0)cnt_even++;
                else cnt_odd++;
            } else {
                if (i % 2 == 0) {
                    ans[i] += cnt_even;
                    ans[i - 1] += cnt_odd;
                } else {
                    ans[i] += cnt_odd;
                    ans[i - 1] += cnt_even;
                }
                cnt_odd = 0;
                cnt_even = 0;
            }
        }
        return ans;
    }
    void solve(std::istream &cin, std::ostream &cout) {
        string s;
        cin >> s;
        vector<int> r_ans(s.size(), 0);
        r_ans = calc(s, 'R');
        reverse(s.begin(), s.end());
        vector<int> l_ans(s.size(), 0);
        l_ans = calc(s, 'L');
        vector<int> ans(s.size(), 0);
        for (int j = 0; j < s.size(); ++j) {
            ans[j] += r_ans[j];
            ans[j] += l_ans[s.size() - 1 - j];
            cout << ans[j] << " ";
        }
        cout << endl;
    }
};


int main() {
    DGatheringChildren solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1784
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String so[] = s.split("");
    int count = 0;
    for(int i = 0;i < 3;i++){
      if(so[i].equals("o")){
        count++;
      }
    }
    System.out.println(700 + 100 * count);
  }
}

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

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    int dp[n + 1000][3];

    for(int i = 1; i <= n; ++i){
        dp[i][0] = max(dp[i - 1][1] + b[i - 1], dp[i - 1][2] + c[i - 1]);
        dp[i][1] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][2] + c[i - 1]);
        dp[i][2] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][1] + b[i - 1]);
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

return 0;
}

Measured memory_bytes: 5568
n, y = map(int, input().split())
y //= 1000
for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - i - j
        if y == 10 * i + 5 * j + k:
            print(i, j, k)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 40684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;


int main(){
  int N,M;
  cin >> N >> M;
  int a;
  int b[N];
  ll dp[N+1];
  for(int i=0;i<N;i++){
    b[i]=1;
    dp[i]=0;
  }
  for(int i=0;i<M;i++){
    cin >> a;
    b[a]=0;
  }
  if(N>1){
    dp[0]=b[0];
    dp[1]=b[1];
    for(int n=2;n<N+1;n++){
      dp[n]=dp[n-1]*b[n-1]+dp[n-2]*b[n-2];
      dp[n]=dp[n]%1000000007;
    }
    cout << dp[N] << endl;
  }else cout << b[0] << endl;
}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

void nextPerm(int* a, int n){
    int tmp, x=-1, y=-1, z;
    for(int i=n-1; i>0; i--){
        if(*(a+i-1) < *(a+i)){
            x = i-1;
            break;
        }
    }
    if(x==-1){
        return;
    }
    for(int i=n-1; i>=0; i--){
        if(*(a+x) < *(a+i)){
            y = i;
            break;
        }
    }
    tmp = *(a+x);
    *(a+x) = *(a+y);
    *(a+y) = tmp;
    for(int i=x+1; i<n; i++){
        z = n-(i-x);
        if(i < z){
            tmp = *(a+z);
            *(a+z) = *(a+i);
            *(a+i) = tmp;
        }else{
            break;
        }
    }
    return;
}

int cmpAsc(const void* a, const void* b){
    int x = *(int*)a, y = *(int*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n, m, r;
    scanf("%d %d %d", &n, &m, &r);
    int town[r], buf[r];
    rep(i, 0, r){
        scanf("%d", &town[i]);
        buf[i] = 0;
    }
    qsort(town, r, sizeof(int), cmpAsc);
    lld wf[n+1][n+1];
    rep(i, 1, n+1){
        rep(j, 1, n+1){
            wf[i][j] = 30000000;
        }
    }
    rep(i, 0, m){
        int a, b;
        lld c;
        scanf("%d %d %lld", &a, &b, &c);
        wf[a][b] = c;
        wf[b][a] = c;
    }
    rep(k, 1, n+1){
        rep(i, 1, n+1){
            rep(j, 1, n+1){
                if(wf[i][j] > wf[i][k] + wf[k][j]){
                    wf[i][j] = wf[i][k] + wf[k][j];
                }
            }
        }
    }
    lld ans = 3000000000;
    while(1){
        int f = 1;
        rep(i, 0, r){
            if(town[i] != buf[i]){
                f = 0;
                break;
            }
        }
        if(f){
            break;
        }
        lld cnt = 0;
        rep(i, 0, r-1){
            cnt += wf[town[i]][town[i+1]];
        }
        if(cnt < ans){
            ans = cnt;
        }
        rep(i, 0, r){
            buf[i] = town[i];
        }
        nextPerm(town, r);
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
int main(){
    using namespace std;
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i] -=1;
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }
    
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]];
        
        if(i>=1 && a[i-1]+1==a[i]){
            ans+=c[a[i]-1];
           // cout<<"\nadd "<<c[a[i]-1]<<" "<<endl;
        }
//        cout<<ans<<", ";
    }
    cout<<ans;

}

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

int main(){
    int num=0,i;
    string s;
    cin>>s;
    for(i=0;i<s.length();i++){
        if(s[i]=='+'){
            num++;
        }
        else{
            num--;
        }
    }
    cout<<num<<endl;;
    return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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; }


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

Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(q)]
mx=0
l=itertools.combinations_with_replacement(range(1,m+1),n)
for y in l:
    temp=0
    for a, b, c, d in x:
        if y[b-1] - y[a-1] == c:
            temp += d
    mx=max(mx,temp)
print(mx)

Measured memory_bytes: 9204
#DPによるフィボナッチ数列
n = int(input())

dp = [-1] * (n+1) #DPテーブルの用意

dp[0] = 1
dp[1] = 1#初期値設定

for i in range(2, n+1):
    dp[i] = dp[i-1] + dp[i-2]

print(dp[n])




Measured memory_bytes: 5600
#include <iostream>
#include <array>
#include <algorithm>

int main(void) {
    std::array<u_int, 4> a;
    std::array<u_int, 4> b;

    while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]
                    >> b[0] >> b[1] >> b[2] >> b[3])
    {
        int hit = 0;
        for (int i = 0; i < 4; ++i) {
            if (a[i] == b[i]) ++hit;
        }

        int blow = -hit;
        std::sort(a.begin(), a.end());
        for (auto v : b) {
            if ( std::binary_search(a.begin(), a.end(), v) ) ++blow;
        }

        std::cout << hit << " " << blow << std::endl;
    }

    return 0;
}

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

using namespace std;

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

	int k = S.length();

	int win = 0;
	for (int i = 0; i < k; i++) {
		if (S[i] == 'o') {
			win++;
		}
	}

	if (win + (15 - k) >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<ctype.h>
 
int main(){
  int n,k;scanf("%d %d",&n,&k);
  char s[n];
  for(int i=0;i<n;i++){
    scanf("%s",&s);
    if(i==k-1) s[i]=tolower(s[i]);
  }
  printf("%s", s);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include <string>
using namespace std;

int main(void){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}


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

int main(void) {
    int A,B,C,D;cin>>A>>B>>C>>D;
    if (B <= C || D <= A) cout << 0 << endl;
    else {
        cout << min(B,D) - max(A,C) << endl;
    }
    return 0;
}

Measured memory_bytes: 256